Tailwind CSS
Tailwind CSS is a utility-first CSS framework for building interfaces by combining atomic utility classes.
Core Philosophy
Unlike traditional semantic CSS frameworks, Tailwind provides low-level utility classes so you can style directly in HTML.
Installation
Via npm
Configuration File
CSS File
Vite Project
Common Utility Classes
Layout
Space
Sizing
Colors
Typography
Borders and border radius
Shadows
Opacity
Responsive Design
Tailwind uses a mobile-first breakpoint system.
Breakpoints
sm: 640px
md: 768px
lg: 1024px
xl: 1280px
2xl: 1536px
Pseudo-classes & States
Dark Mode
Custom Configuration
Extend Theme
Custom Utilities
Custom Components
Common Plugins
Official Plugins
Typography(Typography)
Practical Tips
Use @apply to extract repeated utility classes:
Conditional Classes
Use the clsx or classnames library:
Group & Children
Arbitrary Values
Production Optimization
Tailwind automatically removes unused styles.
JIT Mode
Just-In-Time mode is enabled by default and generates styles on demand.
Editor Support
VS Code Extensions
- Tailwind CSS IntelliSense: autocomplete and previews
- Headwind: automatically sorts class names
FAQ
Style Priority
Use the ! prefix to force a style to apply:
Custom Colors
Best Practices
- Stay consistent and follow the design system.
- Avoid over-abstraction and do not extract components too early.
- Use responsive design with a mobile-first mindset.
- Use configuration well for custom theme colors and spacing.
- Use editor support by installing the IntelliSense extension.
- Componentize complex UI by extracting it into separate files.
References
Last modified on April 17, 2026