mirror of
https://github.com/andwati/copilot-dev-days.git
synced 2026-10-18 02:02:52 +00:00
1.8 KiB
1.8 KiB
description
| description |
|---|
| Read before writing any Tailwind CSS to understand the latest v4 features. |
Tailwind CSS v4 Development Practices
Core Philosophy
- CSS-first configuration via
@themedirective (notailwind.config.js) - Native CSS features: cascade layers,
@property,color-mix(), logical properties - Automatic content detection
Setup
@import "tailwindcss";
@theme Configuration
Define Tokens
@theme {
--color-brand: oklch(0.72 0.11 178);
--font-display: "Inter", sans-serif;
--breakpoint-tablet: 640px;
}
→ Use as: bg-brand, font-display
Multi-theme Pattern
@theme inline {
--color-primary: var(--primary);
}
:root { --primary: #3b82f6; }
.dark { --primary: #60a5fa; }
Use @theme inline for runtime variable resolution.
Rules
- Keep @theme variables flat (top-level only)
- No nesting in @media or selectors
- Use :root for non-Tailwind CSS variables
v4 Features
Native Opacity
<div class="bg-black/50 text-brand/75">
Container Queries
<div class="@container">
<div class="@md:text-lg">
</div>
Arbitrary CSS Variables
<div class="fill-[--my-color] w-[--sidebar-width]">
New Utilities
- 3D:
rotate-x-45,rotate-y-90 - Gradients:
bg-gradient-radial,bg-gradient-conic - Variants:
not-*,color-scheme:*,@starting-style
Migration
Renamed Classes
bg-opacity-50→bg-black/50overflow-ellipsis→text-ellipsisshadow-sm→shadow-xs
Best Practices
- Put design tokens in
@theme - Use
:rootfor regular CSS variables - Trust auto-detection
- Prefer
w-[--custom]over complex config
// Seed prompt // > Fill in a 1-pager copilot instructions (compact, minimal prose), targeted for frontend devs and focused on tailwind v4-specific development essentials; #web_search