Tailwind CSS Best Practices
Styling patterns and conventions for frontend applications. Contains 10 rules covering layout utilities, affordances, color schemes, responsive design, and className handling.
When to Apply
Reference these guidelines when:
- Writing component styles with Tailwind
- Creating layouts (stacks, grids, centering)
- Handling responsive design
- Working with color schemes
- Merging className props
Rules Summary
Layout Utilities (CRITICAL)
layout-stack-utilities - @rules/layout-stack-utilities.md
Use custom stack utilities instead of flex classes.
Available utilities:
v-stack- Vertical stack (flex column)h-stack- Horizontal stack (flex row)v-stack-reverse- Reversed vertical stackh-stack-reverse- Reversed horizontal stackz-stack- Overlapping stack (grid-based, centers children on top of each other)center- Center content both horizontally and verticallyspacer- Flexible spacer that fills available spacecircle- Perfect circle with aspect-ratio 1/1
layout-prefer-gaps - @rules/layout-prefer-gaps.md
Use gap-* on parents instead of child margins.
layout-responsive-stacks - @rules/layout-responsive-stacks.md
Switch layout direction at breakpoints.
Color Schemes (CRITICAL)
color-schemes - @rules/color-schemes.md
Use class-based color schemes with a custom dark variant.
className Handling (CRITICAL)
classname-cn-utility - @rules/classname-cn-utility.md
Always use cn() to merge classNames in components.
classname-prop-types - @rules/classname-prop-types.md
Use proper types for className props.
Affordances (HIGH)
affordance-classes - @rules/affordance-classes.md
Define element-agnostic visual patterns that compose with utilities.
Responsive Design (MEDIUM)
responsive-breakpoints - @rules/responsive-breakpoints.md
Use responsive prefixes with Tailwind defaults.
responsive-text - @rules/responsive-text.md
Scale text responsively.
responsive-capabilities - @rules/responsive-capabilities.md
Design for input capabilities (pointer/hover) instead of device labels.


