Skip to main content
Tailwind is designed to be extended. Whether you need custom utilities, component classes, or arbitrary CSS, there are several ways to add your own styles alongside Tailwind’s utilities.

Custom Utilities with @utility

Create custom utilities that integrate seamlessly with Tailwind’s utility system using the @utility directive:
Use it like any Tailwind utility:

Utilities with Variants

Custom utilities automatically work with Tailwind’s variant system:

Complex Custom Utilities

From the source code, custom utilities integrate with the entire Tailwind system:

Extending the Theme

Add custom values to Tailwind’s theme using the @theme directive:

Custom Colors

Use them with any color utility:

Custom Spacing

Custom Breakpoints

Custom Fonts

Custom Animations

Custom Variants

Create custom variants for special use cases:
Use them in your HTML:

Adding Arbitrary CSS

For styles that don’t fit the utility pattern, add regular CSS:

Plain CSS

Complex Components

Layer System

Tailwind organizes styles into layers. Add your custom styles to the appropriate layer:

Plugins (Advanced)

For maximum flexibility, create JavaScript plugins:

Practical Examples

Form Component System

Card Pattern System

Button System

Best Practices

Use Semantic Names

Leverage @apply Appropriately

Use @apply to compose existing utilities, not to recreate them.

Keep Theme Values Consistent

Document Custom Additions

Testing Custom Styles

Ensure your custom utilities work with Tailwind’s features:
Remember: Custom styles should enhance Tailwind, not replace it. Use custom additions for project-specific needs while leveraging Tailwind’s utilities for common patterns.