-->
Cursor rules file for Tailwind CSS v4.0
--- name: tailwind_v4 description: Guide for using Tailwind CSS v4 instead of v3.x globs: ["**/*.{js,ts,jsx,tsx,mdx,css}"] tags: - tailwind - css ---
CSS-first configuration: Configuration is now done in CSS instead of JavaScript
@theme
directive in CSS instead of tailwind.config.js
@import "tailwindcss";
@theme {
--font-display: "Satoshi", "sans-serif";
--breakpoint-3xl: 1920px;
--color-avocado-500: oklch(0.84 0.18 117.33);
--ease-fluid: cubic-bezier(0.3, 0, 0, 1);
}
Legacy tailwind.config.js
files can still be imported using the @config
directive:
@import "tailwindcss";
@config "../../tailwind.config.js";
CSS import syntax: Use @import "tailwindcss"
instead of @tailwind
directives
@tailwind base; @tailwind components; @tailwind utilities;
@import "tailwindcss";
Package changes:
@tailwindcss/postcss
(not tailwindcss
)@tailwindcss/cli
@tailwindcss/vite
postcss-import
or autoprefixer
anymoreNative CSS cascade layers: Uses real CSS @layer
instead of Tailwind's custom implementation
CSS theme variables: All design tokens are available as CSS variables
--category-name
(e.g., --color-blue-500
, --font-sans
)var(--color-blue-500)
--color-*
: Color utilities like bg-red-500
and text-sky-300
--font-*
: Font family utilities like font-sans
--text-*
: Font size utilities like text-xl
--font-weight-*
: Font weight utilities like font-bold
--tracking-*
: Letter spacing utilities like tracking-wide
--leading-*
: Line height utilities like leading-tight
--breakpoint-*
: Responsive breakpoint variants like sm:*
--container-*
: Container query variants like @sm:*
and size utilities like max-w-md
--spacing-*
: Spacing and sizing utilities like px-4
and max-h-16
--radius-*
: Border radius utilities like rounded-sm
--shadow-*
: Box shadow utilities like shadow-md
--inset-shadow-*
: Inset box shadow utilities like inset-shadow-xs
--drop-shadow-*
: Drop shadow filter utilities like drop-shadow-md
--blur-*
: Blur filter utilities like blur-md
--perspective-*
: Perspective utilities like perspective-near
--aspect-*
: Aspect ratio utilities like aspect-video
--ease-*
: Transition timing function utilities like ease-out
--animate-*
: Animation utilities like animate-spin
Simplified theme configuration: Many utilities no longer need theme configuration
grid-cols-12
, z-40
, and opacity-70
work without configurationdata-selected:opacity-100
don't need configurationDynamic spacing scale: Derived from a single spacing value
--spacing: 0.25rem
mt-21
works automatically)Overriding theme namespaces:
--font-*: initial;
--*: initial;
Container query support: Built-in now, no plugin needed
@container
for container context@sm:
, @md:
, etc. for container-based breakpoints@max-md:
for max-width container queries@min-md:@max-xl:hidden
for ranges3D transforms:
transform-3d
enables 3D transformsrotate-x-*
, rotate-y-*
, rotate-z-*
for 3D rotationscale-z-*
for z-axis scalingtranslate-z-*
for z-axis translationperspective-*
utilities (perspective-near
, perspective-distant
, etc.)perspective-origin-*
utilitiesbackface-visible
and backface-hidden
Gradient enhancements:
bg-linear-45
(renamed from bg-gradient-*
)bg-linear-to-r/oklch
, bg-linear-to-r/srgb
bg-conic
, bg-radial-[at_25%_25%]
Shadow enhancements:
inset-shadow-*
and inset-ring-*
utilitiesshadow-*
and ring-*
New CSS property utilities:
field-sizing-content
for auto-resizing textareasscheme-light
, scheme-dark
for color-scheme
propertyfont-stretch-*
utilities for variable fontsComposable variants: Chain variants together
group-has-data-potato:opacity-100
New variants:
starting
variant for @starting-style
transitionsnot-*
variant for :not()
pseudo-classinert
variant for inert
attributenth-*
variants (nth-3:
, nth-last-5:
, nth-of-type-4:
, nth-last-of-type-6:
)in-*
variant (like group-*
but without adding group
class)open
variant now supports :popover-open
**
variant for targeting all descendantsCustom utilities: Use @utility
directive
@utility tab-4 {
tab-size: 4;
}
Custom variants: Use @variant
directive
@variant pointer-coarse (@media (pointer: coarse));
@variant theme-midnight (&:where([data-theme="midnight"] *));
Plugins: Use @plugin
directive
@plugin "@tailwindcss/typography";
Removed deprecated utilities:
bg-opacity-*
→ Use bg-black/50
insteadtext-opacity-*
→ Use text-black/50
insteadborder-opacity-*
, divide-opacity-*
, etc.Renamed utilities:
shadow-sm
→ shadow-xs
(and shadow
→ shadow-sm
)drop-shadow-sm
→ drop-shadow-xs
(and drop-shadow
→ drop-shadow-sm
)blur-sm
→ blur-xs
(and blur
→ blur-sm
)rounded-sm
→ rounded-xs
(and rounded
→ rounded-sm
)outline-none
→ outline-hidden
(for the old behavior)Default style changes:
currentColor
(was gray-200
)ring
width is now 1px (was 3px)gray-400
)@media (hover: hover)
)Syntax changes:
bg-(--brand-color)
instead of bg-[--brand-color]
theme()
functionUsing a prefix:
@import "tailwindcss" prefix(tw);
tw:flex
, tw:bg-red-500
, tw:hover:bg-red-600
Source detection:
.gitignore
files and binary files)@source "../node_modules/@my-company/ui-lib";
@import "tailwindcss" source(none);
Legacy config files:
@import "tailwindcss";
@config "../../tailwind.config.js";
Dark mode configuration:
@import "tailwindcss";
@variant dark (&:where(.dark, .dark *));
Container customization: Extend with @utility
@utility container {
margin-inline: auto;
padding-inline: 2rem;
}
Using @apply
in Vue/Svelte:
<style>
@import "../../my-theme.css" theme(reference);
/* or */
@import "tailwindcss/theme" theme(reference);
h1 {
@apply font-bold text-2xl text-red-500;
}
</style>
Add this context to your project via the
ctxs
command line integration: