ToolypetMCP
advanced5 minutescss

CSS Custom Properties Theme

Build a theme system using CSS custom properties with gradient, shadow, and animation tokens.

css-variablesthemedesign-tokenscustom-properties

Wann dieses Rezept verwenden

CSS custom properties enable dynamic theming, dark mode toggling, and design token management without JavaScript. The foundation of modern CSS architecture.

Schritte

1

Define gradient tokens

Eingabeaufforderung:Generate primary brand gradient and express as CSS custom properties: --gradient-primary-start: #3b82f6; --gradient-primary-end: #8b5cf6;
2

Define shadow tokens

Eingabeaufforderung:Generate 3 shadow elevation levels as CSS variables: --shadow-sm, --shadow-md, --shadow-lg
3

Define animation tokens

Eingabeaufforderung:Generate easing tokens: --ease-default (smooth), --ease-bounce (springy), --ease-sharp (snappy)
4

Border Radius Generator

Dieses Werkzeug ausprobieren

Define radius tokens

Eingabeaufforderung:Generate border-radius tokens: --radius-sm (4px), --radius-md (8px), --radius-lg (16px), --radius-full (9999px)

Häufig gestellte Fragen

CSS variables vs Sass variables?

CSS variables are runtime (change with JavaScript, media queries, cascade). Sass variables are compile-time only. Use CSS variables for theming and Sass for build-time calculations.

How do CSS variables enable dark mode?

Define variables in :root for light mode and override in [data-theme='dark'] or @media (prefers-color-scheme: dark). All components using the variables automatically switch.

Verwandte Rezepte