addUtilities()
Register static utility classes that don’t accept values.Record<string, CssInJs> | Record<string, CssInJs>[]
required
Object mapping class selectors to CSS-in-JS style definitions. Can be a single object or array of objects.
object
Optional configuration (reserved for future use)
Basic Example
Multiple Selectors
Keyframe Animations
Using Arrays
matchUtilities()
Register dynamic utilities that accept arbitrary values and theme-based values.Record<string, (value: string, extra: { modifier: string | null }) => CssInJs>
required
Object mapping utility names to functions that return CSS styles based on the value
object
Configuration for values, types, and modifiers
string | string[]
Data type(s) to accept for arbitrary values:
'any', 'color', 'length', 'percentage', 'number', etc.Record<string, string>
Named values that can be used with the utility (e.g., from theme)
boolean
Whether to generate negative versions of the utility (e.g.,
-m-4)'any' | Record<string, string>
Opacity modifiers for color utilities or custom modifiers
Basic Example
With Type Validation
Color Utilities with Modifiers
With Negative Values
Using Theme Values
Custom Modifiers
Supported Data Types
When using thetype option with arbitrary values:
Nested Class References
You can reference the utility class name within nested selectors:matchUtilities, the class name is automatically replaced with the actual candidate:
Utilities are automatically wrapped in
@layer utilities and support all Tailwind variants like hover, focus, responsive, etc.