tailwind-v4
БесплатноБез исполняемых скриптовНе проверенTailwind CSS v4 CSS-first configuration, OKLCH design tokens, @theme modes, @utility, @custom-variant dark mode, and v3-to-v4 utility changes. Use when…
от existential-birds★ 92 звезды на GitHubОб этом скилле
Tailwind CSS v4 Best Practices
Quick Reference
Vite Plugin Setup (Vite apps):
// vite.config.ts
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [tailwindcss()],
});
PostCSS Plugin Setup (Next.js, Webpack, or other non-Vite bundlers):
// postcss.config.mjs
export default {
plugins: {
'@tailwindcss/postcss': {},
},
};
CSS Entry Point:
/* src/index.css */
@import "tailwindcss";
@theme & @utility Directives:
@theme inline {
--color-primary: oklch(60% 0.24 262);
--color-surface: oklch(98% 0.002 247);
}
@utility content-auto {
content-visibility: auto;
}
Key Differences from v3
| Feature | v3 | v4 |
|---|---|---|
| Configuration | tailwind.config.js |
@theme in CSS |
| Build Tool | tailwindcss + autoprefixer |
@tailwindcss/vite (Vite) or @tailwindcss/postcss (Next.js/PostCSS) |
| CSS Entry | @tailwind base; @tailwind components; @tailwind utilities; |
@import "tailwindcss"; |
| Colors | rgb() / hsl() |
oklch() (default) |
| Custom Utilities | @layer utilities { .foo { ... } } |
@utility foo { ... } (supports variants like hover:foo) |
| Dark Mode | darkMode in JS config |
Media query by default, or @custom-variant dark (...) in CSS |
| CSS Variables in Arbitrary Values | max-h-[var(--x)] |
max-h-(--x) |
v4 Utility Renames & Removals (Common v3 Regressions)
- Shadows & Radii:
shadow-sm→shadow-xs,shadow→shadow-sm;rounded-sm→rounded-xs,rounded→rounded-sm;blur-sm→blur-xs,blur→blur-sm. - Outline:
outline-none→outline-hidden(for keeping accessible outline in forced-colors mode;outline-nonenow setsoutline-style: none). - Ring default width:
ringdefaults to1pxin v4 (usering-3for v3's3pxdefault). - Opacity modifiers:
bg-opacity-50/text-opacity-50removed — usebg-black/50ortext-white/50. - CSS variables: Use parentheses
bg-(--brand)/max-h-(--var)instead ofbg-[var(--brand)].
shadcn/ui + Tailwind v4 Integration
Modern shadcn/ui on Tailwind v4 maps runtime CSS variables from :root / .dark into Tailwind utility tokens via @theme inline and imports tw-animate-css and shadcn/tailwind.css instead of tailwind.config.js + tailwindcss-animate:
@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";
@custom-variant dark (&:is(.dark *));
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-primary: var(--primary);
}
@theme Directive Modes
default (standard mode)
Generates CSS variables on :root, :host that can be referenced elsewhere:
@theme {
--color-brand: oklch(60% 0.24 262);
}
inline
Inlines values directly without CSS variable indirection (essential when referencing runtime CSS vars like var(--background) inside @theme inline):
@theme inline {
--color-brand: oklch(60% 0.24 262);
}
reference
Inlines values as fallbacks without emitting :root CSS variables:
@theme reference {
--color-internal: oklch(50% 0.1 180);
}
OKLCH Color Format
oklch(L% C H)
- L (Lightness):
0%(black) to100%(white) - C (Chroma):
0(gray) to~0.4(vibrant) - H (Hue):
0–360degrees (red → yellow → green → blue → magenta)
Progressive Disclosure
- Setup & Installation: See references/setup.md for Vite & PostCSS plugin configuration, CSS entry,
@utility, and@source. - Theming & Design Tokens: See references/theming.md for
@thememodes, OKLCH palettes, two-tier semantic tokens, custom fonts, and animations. - Dark Mode Strategies: See references/dark-mode.md for media query,
@custom-variantclass/attribute strategies, FOUC prevention, and reduced motion.
Gates (Setup Verification)
Before recommending @theme choices, OKLCH tokens, or v4 utilities, confirm the project is actually on the v4 integration path:
- Build wiring: Either Vite loads
tailwindcss()from@tailwindcss/vite, or PostCSS loads'@tailwindcss/postcss'(postcss.config.*), and the CSS entry uses@import "tailwindcss";. - Major versions:
package.jsonliststailwindcss(and@tailwindcss/viteor@tailwindcss/postcss) at major 4 (no legacyautoprefixer+ v3 plugin pipeline). - Theme source: New theme tokens and dark variants live in CSS (
@theme,@theme inline,@custom-variant,@utility) — nottailwind.config.jsextendor@layer utilities.
Decision Guide
When to use @theme inline vs @theme
- Use
@theme inlinewhen mapping another CSS variable (--color-primary: var(--primary)), for static tokens that should inline directly, or for@keyframesanimations. - Use
@themewhen you want Ta
Установить tailwind-v4 в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл tailwind-v4?
Tailwind CSS v4 CSS-first configuration, OKLCH design tokens, @theme modes, @utility, @custom-variant dark mode, and v3-to-v4 utility changes. Use when configuring Tailwind v4 with Vite or PostCSS, defining CSS theme variables, or reviewing v4 styles.
Как установить скилл tailwind-v4?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл tailwind-v4 запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic