Tailwind CSS Best Practices
Tailwind CSS v4 guide organized as modular rules. Covers the utility-first model, @theme variables, responsive/state variants, custom styles, performance, accessibility, and the Figma → Tailwind theme workflow for generating design tokens directly from Figma variables.
ROUTING: Which rule file to load
IF setting up Tailwind or understanding how utility classes work:
→ Read rules/core-utility-model.md
IF working with theme variables (@theme), design tokens, colors, fonts, spacing:
→ Read rules/core-theme-variables.md
IF working with responsive design, hover/focus states, dark mode, or custom variants:
→ Read rules/core-responsive-and-states.md
IF adding custom CSS, component classes, base styles, or custom utilities:
→ Read rules/core-custom-styles.md
IF optimizing build size, purging unused classes, or configuring content detection:
→ Read rules/perf-purging-and-scanning.md
IF working on accessibility or dark mode strategies:
→ Read rules/a11y-and-dark-mode.md
IF translating Figma variables/design tokens into Tailwind v4 theme CSS:
→ Read rules/figma-to-theme-workflow.md + see figma-tokens/ templates
Rule index
| Topic |
Description |
File |
| Sections overview |
Categories and reading order |
rules/_sections.md |
| Utility model |
Utility-first principles, composing classes, arbitrary values |
rules/core-utility-model.md |
| Theme variables |
@theme directive, namespaces, extend/override, inline/static |
rules/core-theme-variables.md |
| Responsive & states |
Breakpoints, hover/focus/dark variants, custom variants |
rules/core-responsive-and-states.md |
| Custom styles |
@layer, @utility, @variant, component classes |
rules/core-custom-styles.md |
| Performance |
Content detection, JIT, build optimization |
rules/perf-purging-and-scanning.md |
| A11y & dark mode |
Accessibility utilities, dark mode patterns |
rules/a11y-and-dark-mode.md |
| Figma workflow |
Agent workflow: Figma variables → Tailwind @theme CSS |
rules/figma-to-theme-workflow.md |
Figma → Tailwind theme workflow
This skill includes a dedicated agent workflow to convert Figma design variables into Tailwind v4 @theme CSS files. The workflow is described in rules/figma-to-theme-workflow.md and uses the annotated templates in figma-tokens/ as output targets.
How to trigger it: paste your Figma CSS variables into chat and ask the agent to generate the Tailwind theme files.
Template files in figma-tokens/:
colors.css — --color-* namespace
typography.css — --font-*, --text-*, --font-weight-*, --tracking-*, --leading-*
spacing.css — --spacing and --spacing-*
radius-shadows.css — --radius-*, --shadow-*
breakpoints.css — --breakpoint-*
Rule categories by priority
| Priority |
Category |
Impact |
Prefix |
| 1 |
Utility model & theme |
CRITICAL |
core- |
| 2 |
Responsive & states |
HIGH |
core- |
| 3 |
Custom styles |
HIGH |
core- |
| 4 |
Figma workflow |
HIGH |
(standalone) |
| 5 |
Performance |
MEDIUM-HIGH |
perf- |
| 6 |
Accessibility |
MEDIUM |
a11y- |
Coverage and maintenance
- Coverage map:
rules/_coverage-map.md
- Source: https://tailwindcss.com/docs (v4.2)
- Update when Tailwind releases a new major/minor version with breaking
@theme changes.
1---2name: tailwind-73description: Tailwind CSS v4 best-practices skill covering utility-first patterns, @theme variables, responsive design, dark mode, custom styles, performance, accessibility, and a Figma-to-Tailwind theme generation workflow. Use when the user mentions Tailwind, tailwindcss, @theme, utility classes, Tailwind config, Figma design tokens, or asks to build, configure, audit, or migrate a Tailwind CSS project (including v3 to v4 migrations).4---5
6# Tailwind CSS Best Practices
7
8Tailwind CSS v4 guide organized as modular rules. Covers the utility-first model, `@theme` variables, responsive/state variants, custom styles, performance, accessibility, and the **Figma → Tailwind theme workflow** for generating design tokens directly from Figma variables.
9
10## ROUTING: Which rule file to load
11
12**IF setting up Tailwind or understanding how utility classes work:**
13→ Read `rules/core-utility-model.md`
14
15**IF working with theme variables (`@theme`), design tokens, colors, fonts, spacing:**
16→ Read `rules/core-theme-variables.md`
17
18**IF working with responsive design, hover/focus states, dark mode, or custom variants:**
19→ Read `rules/core-responsive-and-states.md`
20
21**IF adding custom CSS, component classes, base styles, or custom utilities:**
22→ Read `rules/core-custom-styles.md`
23
24**IF optimizing build size, purging unused classes, or configuring content detection:**
25→ Read `rules/perf-purging-and-scanning.md`
26
27**IF working on accessibility or dark mode strategies:**
28→ Read `rules/a11y-and-dark-mode.md`
29
30**IF translating Figma variables/design tokens into Tailwind v4 theme CSS:**
31→ Read `rules/figma-to-theme-workflow.md` + see `figma-tokens/` templates
32
33## Rule index
34
35| Topic | Description | File |
36|-------|-------------|------|
37| Sections overview | Categories and reading order | [rules/_sections.md](rules/_sections.md) |
38| Utility model | Utility-first principles, composing classes, arbitrary values | [rules/core-utility-model.md](rules/core-utility-model.md) |
39| Theme variables | `@theme` directive, namespaces, extend/override, `inline`/`static` | [rules/core-theme-variables.md](rules/core-theme-variables.md) |
40| Responsive & states | Breakpoints, hover/focus/dark variants, custom variants | [rules/core-responsive-and-states.md](rules/core-responsive-and-states.md) |
41| Custom styles | `@layer`, `@utility`, `@variant`, component classes | [rules/core-custom-styles.md](rules/core-custom-styles.md) |
42| Performance | Content detection, JIT, build optimization | [rules/perf-purging-and-scanning.md](rules/perf-purging-and-scanning.md) |
43| A11y & dark mode | Accessibility utilities, dark mode patterns | [rules/a11y-and-dark-mode.md](rules/a11y-and-dark-mode.md) |
44| **Figma workflow** | **Agent workflow: Figma variables → Tailwind `@theme` CSS** | [rules/figma-to-theme-workflow.md](rules/figma-to-theme-workflow.md) |
45
46## Figma → Tailwind theme workflow
47
48This skill includes a dedicated agent workflow to convert Figma design variables into Tailwind v4 `@theme` CSS files. The workflow is described in `rules/figma-to-theme-workflow.md` and uses the annotated templates in `figma-tokens/` as output targets.
49
50**How to trigger it:** paste your Figma CSS variables into chat and ask the agent to generate the Tailwind theme files.
51
52Template files in `figma-tokens/`:
53- `colors.css` — `--color-*` namespace
54- `typography.css` — `--font-*`, `--text-*`, `--font-weight-*`, `--tracking-*`, `--leading-*`
55- `spacing.css` — `--spacing` and `--spacing-*`
56- `radius-shadows.css` — `--radius-*`, `--shadow-*`
57- `breakpoints.css` — `--breakpoint-*`
58
59## Rule categories by priority
60
61| Priority | Category | Impact | Prefix |
62|----------|----------|--------|--------|
63| 1 | Utility model & theme | CRITICAL | `core-` |
64| 2 | Responsive & states | HIGH | `core-` |
65| 3 | Custom styles | HIGH | `core-` |
66| 4 | Figma workflow | HIGH | (standalone) |
67| 5 | Performance | MEDIUM-HIGH | `perf-` |
68| 6 | Accessibility | MEDIUM | `a11y-` |
69
70## Coverage and maintenance
71
72- Coverage map: `rules/_coverage-map.md`
73- Source: https://tailwindcss.com/docs (v4.2)
74- Update when Tailwind releases a new major/minor version with breaking `@theme` changes.