Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Configure and use UnoCSS atomic CSS engine with presets like Wind (Tailwind-compatible), Icons, and Attributify.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/preset-wind4.md
1---2name: preset-wind43description: Tailwind CSS v4 compatible preset with enhanced features4---56# Preset Wind478The Tailwind CSS v4 compatible preset. Enhances preset-wind3 with modern CSS features.910## Installation1112```ts13import { defineConfig, presetWind4 } from 'unocss'1415export default defineConfig({16presets: [17presetWind4(),18],19})20```2122## Key Differences from Wind32324### Built-in CSS Reset2526No need for `@unocss/reset` - reset is built-in:2728```ts29// Remove these imports30import '@unocss/reset/tailwind.css' // ❌ Not needed31import '@unocss/reset/tailwind-compat.css' // ❌ Not needed3233// Enable in config34presetWind4({35preflights: {36reset: true,37},38})39```4041### OKLCH Color Model4243Uses `oklch` for better color perception and contrast. Not compatible with `presetLegacyCompat`.4445### Theme CSS Variables4647Automatically generates CSS variables from theme:4849```css50:root, :host {51--spacing: 0.25rem;52--font-sans: ui-sans-serif, system-ui, sans-serif;53--colors-black: #000;54--colors-white: #fff;55/* ... */56}57```5859### @property CSS Rules6061Uses `@property` for better browser optimization:6263```css64@property --un-text-opacity {65syntax: '<percentage>';66inherits: false;67initial-value: 100%;68}69```7071### Theme Key Changes7273| preset-wind3 | preset-wind4 |74|--------------|--------------|75| `fontFamily` | `font` |76| `fontSize` | `text.fontSize` |77| `lineHeight` | `text.lineHeight` or `leading` |78| `letterSpacing` | `text.letterSpacing` or `tracking` |79| `borderRadius` | `radius` |80| `easing` | `ease` |81| `breakpoints` | `breakpoint` |82| `verticalBreakpoints` | `verticalBreakpoint` |83| `boxShadow` | `shadow` |84| `transitionProperty` | `property` |85| `container.maxWidth` | `containers.maxWidth` |86| Size properties (`width`, `height`, etc.) | Unified to `spacing` |8788## Options8990```ts91presetWind4({92preflights: {93// Built-in reset styles94reset: true,9596// Theme CSS variables generation97theme: 'on-demand', // true | false | 'on-demand'9899// @property CSS rules100property: true,101},102})103```104105### Theme Variable Processing106107Convert rem to px for theme variables:108109```ts110import { createRemToPxProcessor } from '@unocss/preset-wind4/utils'111112presetWind4({113preflights: {114theme: {115mode: 'on-demand',116process: createRemToPxProcessor(),117}118},119})120121// Also apply to utilities122export default defineConfig({123postprocess: [createRemToPxProcessor()],124})125```126127### Property Layer Customization128129```ts130presetWind4({131preflights: {132property: {133// Custom parent wrapper134parent: '@layer custom-properties',135// Custom selector136selector: ':where(*, ::before, ::after)',137},138},139})140```141142Remove `@supports` wrapper:143144```ts145presetWind4({146preflights: {147property: {148parent: false,149},150},151})152```153154## Generated Layers155156| Layer | Description | Order |157|-------|-------------|-------|158| `properties` | CSS `@property` rules | -200 |159| `theme` | Theme CSS variables | -150 |160| `base` | Reset/preflight styles | -100 |161162## Theme.defaults163164Global default configuration for reset styles:165166```ts167import type { Theme } from '@unocss/preset-wind4/theme'168169const defaults: Theme['default'] = {170transition: {171duration: '150ms',172timingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',173},174font: {175family: 'var(--font-sans)',176featureSettings: 'var(--font-sans--font-feature-settings)',177variationSettings: 'var(--font-sans--font-variation-settings)',178},179monoFont: {180family: 'var(--font-mono)',181// ...182},183}184```185186## Compatibility Notes187188### presetRemToPx189190Not needed - use built-in processor instead:191192```ts193presetWind4({194preflights: {195theme: {196process: createRemToPxProcessor(),197}198},199})200```201202### presetLegacyCompat203204**Not compatible** with preset-wind4 due to `oklch` color model.205206## Migration from Wind32072081. Update theme keys according to the table above2092. Remove `@unocss/reset` imports2103. Enable `preflights.reset: true`2114. Test color outputs (oklch vs rgb)2125. Update any custom theme extensions213214```ts215// Before (wind3)216theme: {217fontFamily: { sans: 'Roboto' },218fontSize: { lg: '1.125rem' },219breakpoints: { sm: '640px' },220}221222// After (wind4)223theme: {224font: { sans: 'Roboto' },225text: { lg: { fontSize: '1.125rem' } },226breakpoint: { sm: '640px' },227}228```229230## When to Use Wind4231232Choose **preset-wind4** when:233- Starting a new project234- Targeting modern browsers235- Want built-in reset and CSS variables236- Following Tailwind v4 conventions237238Choose **preset-wind3** when:239- Need legacy browser support240- Migrating from Tailwind v3241- Using presetLegacyCompat242- Want stable, proven preset243244<!--245Source references:246- https://unocss.dev/presets/wind4247-->248