Skip to content

Theming

Every color and radius is a CSS variable in one file you own.

Components never use raw colors, only tokens such as bg-primary or text-muted-foreground. Change a variable in src/fizzy.css and every component follows.

Tokens

  • --background
  • --foreground
  • --primary
  • --primary-foreground
  • --secondary
  • --muted
  • --muted-foreground
  • --accent
  • --destructive
  • --border
  • --ring

Presets and the theme editor

npx fizzy-ui init --theme blue sets a color preset (neutral, blue, green, rose, violet, orange) in src/fizzy.css, light and dark, and keeps your other edits. Or pick one here, change the radius or any color, and copy the CSS. Every preset meets WCAG AA contrast; the editor checks your colors as you go.

Preset

Light

BadgeMuted

Dark

BadgeMuted
Color tokens
TokenLightDark
--background
--foreground
--primary
--primary-foreground
--secondary
--secondary-foreground
--muted
--muted-foreground
--accent
--accent-foreground
--destructive
--destructive-foreground
--border
--ring

Contrast

  • light: foreground on background19.8:1 passes
  • light: primary-foreground on primary17.2:1 passes
  • light: secondary-foreground on secondary16.4:1 passes
  • light: muted-foreground on background5.1:1 passes
  • light: muted-foreground on muted4.6:1 passes
  • light: accent-foreground on accent16.4:1 passes
  • light: destructive-foreground on destructive4.6:1 passes
  • light: destructive on background4.8:1 passes
  • light: ring on background3.5:1 passes
  • dark: foreground on background19.0:1 passes
  • dark: primary-foreground on primary14.2:1 passes
  • dark: secondary-foreground on secondary14.5:1 passes
  • dark: muted-foreground on background7.6:1 passes
  • dark: muted-foreground on muted5.8:1 passes
  • dark: accent-foreground on accent14.5:1 passes
  • dark: destructive-foreground on destructive6.8:1 passes
  • dark: destructive on background6.8:1 passes
  • dark: ring on background4.2:1 passes

WCAG AA: 4.5:1 for text, 3:1 for the focus ring. Every preset passes; the site's tests check them.

These are the default tokens. Pick a preset or edit a color.

Dark mode

The .dark block overrides the same variables. Put the class on <html> to switch, as the toggle on this site does.

Sizes

Controls come in four sizes, xs, sm, md (the default) and lg, from one scale in fizzy.css, so controls of the same size line up. Set it on one component with size="sm", or on any container with data-size="sm": everything inside follows, like a density setting. The nearest one wins.

€
  • --fz-h is the control height (28, 32, 36, 40px); --fz-px, --fz-field-px and --fz-text the padding and text.
  • Avatar, badge and spinner have their own scale under the same names. Dialogs, menus, tables and other containers have one size.
  • xs stays above the 24px minimum pointer target (WCAG 2.5.8).

Motion

Panels open with Apple-style springs: brief, no bounce, never in the way. Dialogs and popups fade in and grow slightly from their trigger, sheets slide in from their edge, the accordion grows to its height and the switch thumb settles with a hint of bounce. Dialogs and sheets leave the way they came, a little faster; popups and tooltips fade out quickly, with focus already back on their trigger. Submenus, menubars and trees stay instant; the tab highlight slides and the checkbox mark springs in.

  • --fz-spring and --fz-spring-snappy are the curves (bounce 0 and 0.15).
  • --fz-duration-* set the timing. Set one to 0s to turn that motion off.
  • With Reduce Motion on, scale and slide become fades, bounce goes away and the accordion changes at once.

Right-to-left

Components use logical properties (start and end, not left and right), so they follow the text direction: rows, padding, borders, chevrons, the switch thumb, the slider fill, popups and the tab highlight all mirror. Set dir="rtl" on <html>. For one part of a page, import Dir from @angular/cdk/bidi and put dir="rtl" on its container, so the arrow keys and popups follow it too.

₪
אדום
כתום
צהוב
ירוק
כחול
סגול
ורוד
  • Arrow keys follow the direction: in a right-to-left tab list or toolbar, Left moves to the next item.
  • A sheet's side is physical (left, right): pick it from the direction.

The file

/* fizzy-ui theme tokens. Edit freely: components only reference these variables. */
@custom-variant dark (&:where(.dark, .dark *));

:root {
  --radius: 0.5rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.54 0 0); /* 4.5:1 on muted and background */
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(0.922 0 0);
  --ring: oklch(0.63 0 0); /* 3:1 on background and muted (focus ring) */

  /* Motion: Apple-style springs (WWDC23 "Animate with springs"), sampled for CSS. A curve spans
     1.3x the spring's duration so it can settle: 650ms is a 0.5s spring. Set a duration to 0s to
     turn that motion off. */
  --fz-spring: linear(0, 0.064, 0.197, 0.346, 0.486, 0.605, 0.702, 0.779, 0.837, 0.882, 0.914, 0.939, 0.956, 0.969, 0.978, 0.984, 0.989, 0.992, 0.995, 0.996, 1); /* bounce 0 */
  --fz-spring-snappy: linear(0, 0.066, 0.21, 0.375, 0.532, 0.666, 0.772, 0.853, 0.91, 0.949, 0.975, 0.991, 1, 1.004, 1.006, 1.006, 1.006, 1.005, 1.004, 1.003, 1); /* bounce 0.15 */
  --fz-duration-panel: 650ms; /* dialog, sheet */
  --fz-duration-popup: 400ms; /* popover, menu, select, combobox, accordion */
  --fz-duration-control: 330ms; /* switch */
  --fz-duration-fade: 150ms; /* tooltip; popups closing */
  --fz-duration-exit: 260ms; /* dialog, sheet closing: a 0.2s spring, leaving is quicker than arriving */
}

/* Enter animations. Keyframes, not transitions: CDK shows a panel before adding its classes, so
   @starting-style would come too late. */
@keyframes fz-pop-in { from { opacity: 0; scale: 0.96; } }
@keyframes fz-fade-in { from { opacity: 0; } }
@keyframes fz-fade-out { to { opacity: 0; } }
@keyframes fz-slide-in-right { from { translate: 100% 0; } }
@keyframes fz-slide-in-left { from { translate: -100% 0; } }
@keyframes fz-slide-in-top { from { translate: 0 -100%; } }
@keyframes fz-slide-in-bottom { from { translate: 0 100%; } }
@keyframes fz-toast-in { from { opacity: 0; translate: 0 100%; } }
@keyframes fz-indeterminate { from { background-position: -70% 0; } to { background-position: 170% 0; } }
@keyframes fz-pop-out { to { opacity: 0; scale: 0.96; } }
@keyframes fz-slide-out-right { to { translate: 100% 0; } }
@keyframes fz-slide-out-left { to { translate: -100% 0; } }
@keyframes fz-slide-out-top { to { translate: 0 -100%; } }
@keyframes fz-slide-out-bottom { to { translate: 0 100%; } }

/* Reduce Motion (Apple HIG): fades instead of scale and slide, no bounce, no height animation. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --fz-spring-snappy: var(--fz-spring);
  }
  @keyframes fz-pop-in { from { opacity: 0; } }
  @keyframes fz-slide-in-right { from { opacity: 0; } }
  @keyframes fz-slide-in-left { from { opacity: 0; } }
  @keyframes fz-slide-in-top { from { opacity: 0; } }
  @keyframes fz-slide-in-bottom { from { opacity: 0; } }
  @keyframes fz-toast-in { from { opacity: 0; } }
  @keyframes fz-indeterminate { from, to { background-size: 100% 100%; opacity: 1; } 50% { background-size: 100% 100%; opacity: 0.4; } }
  @keyframes fz-pop-out { to { opacity: 0; } }
  @keyframes fz-slide-out-right { to { opacity: 0; } }
  @keyframes fz-slide-out-left { to { opacity: 0; } }
  @keyframes fz-slide-out-top { to { opacity: 0; } }
  @keyframes fz-slide-out-bottom { to { opacity: 0; } }
}

/* Sizes: data-size="xs|sm|md|lg" on a component (its size input sets it) or on any container, which
   sizes everything inside it like a density setting; the nearest one wins. md is the default.
   Controls of the same size line up: an sm input is as tall as an sm button. xs stays above the
   24px minimum pointer target (WCAG 2.5.8). */
:root,
[data-size='md'] {
  --fz-h: 2.25rem; /* control height */
  --fz-px: 1rem; /* button padding */
  --fz-field-px: 0.75rem; /* input padding */
  --fz-text: 0.875rem;
  --fz-avatar: 2rem;
  --fz-spinner: 1rem;
  --fz-badge-text: 0.75rem;
}
[data-size='xs'] {
  --fz-h: 1.75rem;
  --fz-px: 0.5rem;
  --fz-field-px: 0.5rem;
  --fz-text: 0.75rem;
  --fz-avatar: 1.5rem;
  --fz-spinner: 0.75rem;
  --fz-badge-text: 0.625rem;
}
[data-size='sm'] {
  --fz-h: 2rem;
  --fz-px: 0.75rem;
  --fz-field-px: 0.625rem;
  --fz-text: 0.875rem;
  --fz-avatar: 1.75rem;
  --fz-spinner: 0.875rem;
  --fz-badge-text: 0.6875rem;
}
[data-size='lg'] {
  --fz-h: 2.5rem;
  --fz-px: 1.5rem;
  --fz-field-px: 0.875rem;
  --fz-text: 1rem;
  --fz-avatar: 2.5rem;
  --fz-spinner: 1.25rem;
  --fz-badge-text: 0.875rem;
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --destructive-foreground: oklch(0.145 0 0);
  --border: oklch(1 0 0 / 10%);
  --ring: oklch(0.556 0 0);
}

@theme inline {
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-border: var(--border);
  --color-ring: var(--ring);
  --ease-spring: var(--fz-spring);
  --ease-spring-snappy: var(--fz-spring-snappy);
  --animate-fz-popup: fz-pop-in var(--fz-duration-popup) var(--fz-spring);
  --animate-fz-dialog: fz-pop-in var(--fz-duration-panel) var(--fz-spring);
  --animate-fz-tooltip: fz-fade-in var(--fz-duration-fade) ease-out;
  --animate-fz-toast: fz-toast-in var(--fz-duration-popup) var(--fz-spring);
  --animate-fz-indeterminate: fz-indeterminate 1.5s ease-in-out infinite;
  --animate-fz-fade-out: fz-fade-out var(--fz-duration-fade) ease-out forwards;
  --animate-fz-sheet-right: fz-slide-in-right var(--fz-duration-panel) var(--fz-spring);
  --animate-fz-sheet-left: fz-slide-in-left var(--fz-duration-panel) var(--fz-spring);
  --animate-fz-sheet-top: fz-slide-in-top var(--fz-duration-panel) var(--fz-spring);
  --animate-fz-sheet-bottom: fz-slide-in-bottom var(--fz-duration-panel) var(--fz-spring);
  --animate-fz-dialog-out: fz-pop-out var(--fz-duration-exit) var(--fz-spring) forwards;
  --animate-fz-sheet-right-out: fz-slide-out-right var(--fz-duration-exit) var(--fz-spring) forwards;
  --animate-fz-sheet-left-out: fz-slide-out-left var(--fz-duration-exit) var(--fz-spring) forwards;
  --animate-fz-sheet-top-out: fz-slide-out-top var(--fz-duration-exit) var(--fz-spring) forwards;
  --animate-fz-sheet-bottom-out: fz-slide-out-bottom var(--fz-duration-exit) var(--fz-spring) forwards;
}

@layer base {
  * { border-color: var(--color-border); }
  body { background: var(--color-background); color: var(--color-foreground); }
}