Kind: Type
Source: src/helper/css/common.ts
Part of: Helper
A callback function called when an invalid slug is returned from ClassNameSlug.
OnInvalidSlug defines the callback invoked when ClassNameSlug returns a slug that is not valid. Use it to report the invalid value or stop processing before the generated class name is applied.
Definition
ts(slug: string) => void
Diagram
mermaidgraph LR A[ClassNameSlug] --> B{Slug valid?} B -->|Yes| C[Apply class name] B -->|No| D[OnInvalidSlug callback] D --> E[Report or throw]
Usage
tsimport type { OnInvalidSlug } from "./helper/css/common";
const onInvalidSlug: OnInvalidSlug = (slug) => {
throw new Error(`Invalid CSS class slug returned: ${slug}`);
};
// Provide `onInvalidSlug` where the CSS naming configuration accepts it.
AI Coding Instructions
- Type callback implementations as
OnInvalidSlugso parameter and return types stay aligned with the shared contract. - Treat the received slug as invalid input; do not apply it as a CSS class name.
- Throw an error when invalid slugs should stop the build or render path.
- Keep
ClassNameSlugoutput compatible with the slug rules expected by the CSS naming flow.
Was this page helpful?