Article Title
Content...
--- name: tailwindcss displayName: Tailwind CSS description: Tailwind CSS v4 utility-first styling patterns including responsive design, dark mode, and custom configuration. Use when styling with Tailwind, adding utility classes, configuring Tailwind, setting up dark mode, or customizing the theme. version: 1.0.0 --- # Tailwind CSS v4 Development Guidelines Best practices for using Tailwind CSS v4 utility classes effectively. **Note**: Tailwind CSS v4 (released January 2025) uses a CSS-first configuration approach. If you need v3 compatibility, tailwind.config.js is still supported. ## Core Principles 1. **Utility-First**: Use utility classes instead of custom CSS 2. **Mobile-First**: Design for mobile, then scale up with responsive modifiers 3. **Component Extraction**: Extract repeated patterns into components 4. **Consistent Spacing**: Use Tailwind's spacing scale 5. **Custom Configuration**: Extend the default theme for brand consistency ## Basic Utilities ### Layout ```tsx // Flexbox
Paragraph text with comfortable line height.
Label ``` ### Colors ```tsx // Text colorsText
// Background colors
Card content goes here.
We'll never share your email.
Hover the container
Description
Content...
This text will be truncated with ellipsis if too long
This text will show max 3 lines with ellipsis
``` ## Best Practices 1. **Use Consistent Spacing**: Stick to Tailwind's spacing scale 2. **Responsive by Default**: Always consider mobile-first design 3. **Extract Components**: Avoid repeating long class lists 4. **Use Theme Colors**: Define custom colors in config, not arbitrary values 5. **Leverage @apply Sparingly**: Prefer utility classes in JSX 6. **Enable Dark Mode**: Plan for dark mode from the start 7. **Use Plugins**: Leverage official plugins for common needs 8. **Optimize Production**: Ensure purge is configured correctly ## Additional Resources For detailed information, see: - [Utility Patterns](resources/utility-patterns.md) - [Component Library](resources/component-library.md) - [Configuration Guide](resources/configuration.md)