tailwindcss-custom-styles
@utility, @variant, @apply, custom CSS
When & Why to Use This Skill
This Claude skill specializes in advanced Tailwind CSS customization, enabling developers to extend the framework's capabilities through custom directives. It facilitates the creation of bespoke utility classes, conditional variants, and organized CSS architectures using @utility, @variant, and @apply, significantly improving frontend development efficiency and design system consistency.
Use Cases
- Design System Development: Defining unique brand utilities like 'glass-effect' or custom shadows using @utility to ensure visual consistency across a web application.
- Advanced Theming: Implementing complex conditional styling and custom themes (e.g., 'midnight-theme') by leveraging @custom-variant for highly responsive and adaptive UIs.
- Component Refactoring: Cleaning up bloated HTML templates by using @apply to extract repetitive utility patterns into semantic, reusable CSS component classes.
- CSS Architecture Optimization: Organizing global styles and preventing specificity conflicts by correctly utilizing @layer to manage base, component, and utility hierarchies.
| name | tailwindcss-custom-styles |
|---|---|
| description | @utility, @variant, @apply, custom CSS |
Custom Styles
@utility - Créer une utility
@utility glass-effect {
backdrop-filter: blur(10px);
background: rgba(255, 255, 255, 0.1);
}
/* Usage: class="glass-effect hover:glass-effect" */
@variant - Style conditionnel
.card {
background: white;
@variant dark { background: #1a1a2e; }
@variant hover { transform: scale(1.05); }
}
@custom-variant - Nouveau variant
@custom-variant theme-midnight (&:where([data-theme="midnight"] *));
/* Usage: theme-midnight:bg-black */
@apply - Inline utilities
.btn-primary {
@apply bg-blue-500 text-white px-4 py-2 rounded-lg;
}
@layer - Organisation CSS
@layer components {
.card { @apply bg-white shadow-md rounded-xl p-4; }
}