Tailwind CSS
tailwind/theme-tokens
An arbitrary value used again and again (bg-[#0a7a3e], p-[18px]) becomes a theme variable in @theme with its own utility.
drobnastatycznefe-tailwind
Dlaczego
Square-bracket values are an escape hatch for one-off cases. The same #0a7a3e typed in ten places is a design token without a name: changing the brand colour means a search and replace, near-duplicates (#0a7a3f) creep in, and dark mode cannot redefine it.
Poprawka
Define it once in the CSS entry file: @theme { --color-brand-600: #0a7a3e; --spacing-gutter: 1.125rem; }, then use the generated utilities (bg-brand-600, p-gutter) and the CSS variable (var(--color-brand-600)) wherever plain CSS needs it. Tokens that are not Tailwind namespaces go in :root (see css/design-tokens).
Przykłady
<!-- bad -->
<button class="bg-[#0a7a3e] px-[18px]">Save</button> <a class="text-[#0a7a3e]">Help</a> <hr class="border-[#0a7a3e]">
<!-- good -->
<button class="bg-brand-600 px-gutter">Save</button> <a class="text-brand-600">Help</a> <hr class="border-brand-600">Źródła
Fakty
- Identyfikator
tailwind/theme-tokens- Waga
- drobna
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
htmlangularvuesvelteastrojsx- Tylko w projektach z
tailwind- Uczy jej skill
fe-tailwindTailwind CSS- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain tailwind/theme-tokens