| name | css |
| description | Guides styling implementation using TailwindCSS + CSS Modules. Triggered when handling component styles, layout design, or CSS patterns. |
CSS Styling Guide
This skill provides mandatory specifications for combining TailwindCSS + CSS Modules for styling implementation in this project.
1. Architecture Overview
This project adopts a hybrid styling strategy:
- TailwindCSS: For simple, utility-first styles and layouts.
- CSS Modules: For complex state management, component-specific styles, and high maintainability needs.
- Rsbuild + Lightning CSS: Provides modern CSS processing with PostCSS support.
2. Styling Strategy Decision Tree
When to Use TailwindCSS
<div className='flex items-center gap-3 p-4'>
<span className='text-std-600'>Content</span>
</div>
When to Use CSS Modules
import styles from './index.module.css'
<div className={`w_100 border_box relative${styles._local}`}>
<button className='btn_copy'></button>
</div>
3. TailwindCSS Patterns
3.1 Multi-line Class Naming
<div
className='
flex
items-center justify-center
w-18 h-screen
is_drag
'
>
<Icon size={20}></Icon>
</div>
<div className='flex items-center justify-center w-18 h-screen is_drag'>
3.2 Conditional Styles with Template Strings
const Index = ({ fold }: { fold: boolean }) => {
return (
<nav
className={`
relative
flex flex-col
h-full
${fold ? 'w-18 items-center justify-center' : 'border-std-900/8 w-60 border-r py-2'}
`}
>
</nav>
)
}
3.3 Global Utilities
<div className='is_drag'></div> // Allow dragging
<div className='no_drag clickable'></div> // Disallow dragging, allow clicking
<svg className='lucide'></svg> // Apply 1.8px line width
<div className='clickable'></div> // cursor pointer
<div className='border_box'></div> // box-sizing: border-box
<div className='w_100'></div> // width: 100%
4. CSS Modules Patterns
4.1 File Structure
@reference '../../../styles/index.css';
._local {
&:hover {
}
:global {
}
}
4.2 Nested States and :global
._local {
padding: 16px 0;
&:hover {
:global {
.btn_copy {
opacity: 1;
}
}
}
}
:global {
.btn_copy {
opacity: 0;
transition-property: opacity;
&:hover {
@apply bg-std-300;
}
}
}
4.3 Using @apply
._local {
@apply rounded-xl;
padding: 16px 0;
:global {
.lang {
@apply text-std-400;
}
}
}
4.4 CSS Variables
._local {
--margin_y: 1.2em;
p {
margin-block: var(--margin_y);
}
}
5. Color System
The project uses semantic color names:
'text-std-800'
'text-std-600'
'text-std-400'
'text-std-white'
'text-std-black'
'bg-std-100'
'bg-std-200'
'bg-std-300'
'bg-std-800'
'border-std-200'
'border-std-900/8'
6. Constraints and Best Practices
6.1 Naming Conventions
- TailwindCSS: Use standard utility class names.
- CSS Modules: Class names must use
snake_case.
- CSS Variables: Use
snake_case with -- prefix.
- Component Container: Always use
_local for the main container class name.
6.2 Code Style
- TailwindCSS: Use line breaks for better readability.
- CSS Modules: No comments. Use Tab indentation.
- Blank Lines: Separate different logical areas with blank lines.
6.3 Performance and Maintenance
- Avoid Long Strings: Don't create TailwindCSS strings exceeding 100 characters. Use CSS Modules instead.
- No Inline Styles: Avoid inline
style props unless absolutely necessary.
- No !important: Absolutely never use
!important in CSS Modules.