Theming
@theme default . Override it in your own @theme , on a subtree or on a single instance — components never hardcode a value.
How tokens work
theme.css declares the tokens inside one @theme default block. Tailwind compiles them to utilities (bg-primary, text-muted-foreground, rounded-button) and to plain CSS custom properties on :root. Because they are defaults, anything you declare in a regular @theme wins regardless of import order.
Semantic names come in families:
--color-<name>with-foregroundand-hovercompanions (primary,secondary,info,success,warning,error,accent)- Surfaces and text:
background,app,subtle,muted,foreground… --radius-<component>, compiled torounded-<component>--shadow-*for elevation and focus rings,--ease-*and--duration-*for motion
Override globally
Redefine tokens in your stylesheet's @theme block:
/* styles.css — after @import '@vigdx/ui/theme.css' */
@theme {
--color-primary: oklch(0.55 0.2 150);
--color-primary-hover: oklch(0.5 0.19 150);
--color-primary-active: oklch(0.45 0.18 150);
--radius-button: 9999px;
} Without Tailwind, with the precompiled @vigdx/ui/styles.css, declare the same custom properties in plain CSS. The file keeps its tokens in the vigdx cascade layer, so your declarations outside it win whatever the import order. Unlike an @theme override with Tailwind, a :root override applies in dark mode too (it outranks the kit's .dark palette): re-declare under .dark every token dark mode changes, for a brand color the whole family.
/* styles.css — after @import '@vigdx/ui/styles.css' (no Tailwind) */
:root {
--color-primary: #1f6f4a;
--color-primary-hover: #185c3d;
--color-primary-active: #134a31;
--color-primary-foreground: #ffffff;
--radius-button: 9999px;
}
/* :root applies in both schemes: re-declare the whole family for dark mode */
.dark {
--color-primary: #5fc796;
--color-primary-hover: #84d5ae;
--color-primary-active: #a9e2c6;
--color-primary-foreground: #0b0e14;
}Whichever way you override, keep the contrast contract.
Override a subtree or one instance
Tokens are custom properties, so they cascade. Set them on any element to re-theme what is inside it — try it:
theme defaultContrast check
| Pair | Used for | Ratio | Minimum | Result |
|---|
<!-- Every button inside this section becomes a pill -->
<section style="--radius-button: 9999px">
<vig-button label="Get started" />
</section>
<!-- One instance -->
<vig-button style="--radius-button: 0" label="Sharp" />.marketing-hero {
--color-primary: var(--color-accent);
--color-primary-hover: var(--color-accent-hover);
}WarningOverlays render outside the subtree
Inline components follow subtree overrides. Body-level overlays (menus, dialogs, tooltips) render outside the subtree and inherit from :root.
Customizing: tokens → parts → class
Reach for the three styling layers in this order:
- Tokens. Most changes are a custom property: a color, a radius, a duration. They apply everywhere the token is used and survive kit updates.
- Parts. Each component marks its meaningful internal elements with a stable
data-partattribute and the component'sdata-scope—trigger,panel,option,close… — and exposes state throughdata-stateandaria-*. Every component page lists its parts under "Styling hooks". Parts are public API: the CI gate records them, so a part is only removed in a major release. - A host class for layout around the component (width, margins, grid placement).
/* styles.css — global CSS, outside any @layer (or in a layer after utilities) */
[data-scope='chip'][data-part='close'] {
color: var(--color-error);
}
/* Overlay panels render outside the host; the scope still matches them */
[data-scope='select'][data-part='panel'] {
max-height: 20rem;
}
/* State comes from data-state and aria-* */
[data-scope='accordion'][data-part='trigger'][data-state='open'] {
font-weight: 700;
}<!-- The same, as a Tailwind arbitrary variant on the host -->
<vig-chip
class="[&_[data-scope=chip][data-part=close]]:text-error"
label="Urgent"
closable
/> Select a part by its data-scope and data-part together. A descendant selector such as vig-multi-select [data-part=label] would also hit the parts of kit components nested inside (the chips of a multi-select), and misses overlay panels, which render outside the host.
No !important is needed, as long as the rule is in the right place. The kit's classes are Tailwind utilities, which your build compiles into Tailwind's @layer utilities. A rule wins over them, whatever its specificity, when it is in global CSS outside any cascade layer, or in a layer ordered after utilities. It loses inside @layer components or @layer base, in a stylesheet imported with @import … layer(x) unless that layer comes after utilities, and in a component's own (emulated-encapsulation) styles, which never reach the kit's elements without ::ng-deep. With the precompiled @vigdx/ui/styles.css the kit's utilities are unlayered and scoped to its elements (.p-2:where([data-scope]), specificity 0,1,0): a part selector (0,2,0) beats them anywhere, a rule of equal specificity when loaded after styles.css, and a rule inside any cascade layer never does. Put part overrides in a global stylesheet:
/* styles.css — to keep your own rules layered, order an app layer last */
@layer theme, base, components, utilities, app;
@import 'tailwindcss';
@import '@vigdx/ui/theme.css';
@layer app {
[data-scope='chip'][data-part='close'] {
color: var(--color-error);
}
} Overlays that animate (dialog, drawer, menus, popover, command menu, the tree select, cascade select and color picker panels, the image and galleria viewer) mark the animating element with data-opening while their entrance plays and data-closing while their exit plays, and remove the attribute once the transition settles (two seconds at most). Both are stable hooks, listed with each component's parts: style an entrance or exit with Tailwind's data-opening: and data-closing: variants, and the test harnesses of @vigdx/ui/testing wait on them.
An arbitrary variant such as [&_[data-scope=chip][data-part=close]]:text-error stays inside the utilities layer, but its selector (a class plus two attributes) is more specific than the part's own single-class utilities. For hover and focus styles, which the kit also sets with variants, prefer global CSS. The Storybook story “Core / Styling hooks” checks these cases in a real browser, with zero-specificity :where() rules.
Dark mode
theme.css ships a dark palette under the .dark class: semantic tokens only, with brand and status hues lifted to hold WCAG AA on dark grounds. Put the class on <html> — this site does exactly that from the theme switch in the site navigation.
// Put .dark on <html> so body-level overlays (menus, dialogs) follow too.
document.documentElement.classList.toggle('dark', prefersDark);/* Make Tailwind's dark: variant follow the same class */
@custom-variant dark (&:where(.dark, .dark *));
/* Re-theme dark mode: declare your own .dark block after the import */
.dark {
--color-primary: #7aa2ff;
--color-background: #0f141c;
}Contrast contract
The components draw tokens on one another: --color-primary-foreground on --color-primary, a slider fill on a --color-muted track. The defaults and the dark palette meet WCAG AA for every such pair; when you override a token, keeping them there is yours to do. Automated audits miss many of these pairs (text over pseudo-elements and translucent tints, colors that only appear on hover), so check them whenever a token changes. The playground above computes them live for the colors you pick.
- Text, 4.5:1: every text color on the surface it sits on, including each
-foregroundon its fill and on the fill's-hover, and the status hues as text onbackground(messages, field errors). - Text on tints, 4.5:1: each hue on its own 10% tint over
background(soft badges, hovered text and outlined buttons), and each-hovertoken on its hue's 15% tint (pressed buttons, whose text takes the-hovertoken). Composite the tint overbackgroundbefore measuring; a hue that passes onbackgroundcan fail on its own tint. - Non-text, 3:1: control boundaries (
--color-border-control) and state indicators:--color-primaryonbackground,muted,subtleandapp(checked fills, slider, progress and knob fills on muted tracks, selection marks), and--color-ratingonbackgroundandmuted. - Focus rings derive from
--color-primary(and--color-erroron invalid fields). The offset ring draws abackgroundgap and thenprimary, soprimaryneeds 3:1 againstbackgroundand against whatever surrounds the control. - Forced colors (Windows High Contrast) replace token colors with system colors and drop box shadows. Every focus ring is paired with an outline and states map to
Highlight,GrayTextandCanvasText, so no token override can break that mode. Your own CSS around the kit must not convey state with a token color or a shadow alone. - Dark mode: check every pair again under
.dark. A dark theme on a class of its own, without the kit's.dark, must re-declare the status hues and--color-ratingas well: the light ones give status text about 3.1:1 on a near-black surface.
WarningExample: a stock emerald primary
Tailwind's emerald-500 (#10b981) as --color-primary gives white button text 2.54:1 and a slider fill on slate-100 2.32:1, below both minimums. emerald-700 (#047857) holds 5.48:1 and 5.01:1.
| Pair | Minimum | Used for |
|---|---|---|
--color-foreground on --color-background | 4.5:1 | Body text |
--color-foreground-soft on --color-background | 4.5:1 | Secondary text |
--color-muted-foreground on --color-background | 4.5:1 | Hints, placeholders, meta text |
--color-muted-foreground on --color-subtle | 4.5:1 | Hints on read-only fields, wells and avatars |
--color-link on --color-background | 4.5:1 | Inline links |
--color-primary on --color-background | 4.5:1 | Text and outlined buttons, soft badges, selected items |
--color-primary-foreground on --color-primary | 4.5:1 | Primary buttons, checked chips |
--color-primary-foreground on --color-primary-hover | 4.5:1 | Hovered primary buttons |
--color-primary-foreground on --color-primary-active | 4.5:1 | Pressed primary buttons |
--color-secondary-foreground on --color-secondary | 4.5:1 | Secondary chips and buttons |
--color-secondary-foreground on --color-secondary-hover | 4.5:1 | Hovered secondary chips and buttons |
--color-info-foreground on --color-info | 4.5:1 | Solid info buttons and badges |
--color-info-foreground on --color-info-hover | 4.5:1 | Hovered info buttons |
--color-info on --color-background | 4.5:1 | Info text: messages |
--color-success-foreground on --color-success | 4.5:1 | Solid success buttons and badges |
--color-success-foreground on --color-success-hover | 4.5:1 | Hovered success buttons |
--color-success on --color-background | 4.5:1 | Success text: messages |
--color-warning-foreground on --color-warning | 4.5:1 | Solid warning buttons and badges |
--color-warning-foreground on --color-warning-hover | 4.5:1 | Hovered warning buttons |
--color-warning on --color-background | 4.5:1 | Warning text: messages |
--color-error-foreground on --color-error | 4.5:1 | Solid error buttons and badges |
--color-error-foreground on --color-error-hover | 4.5:1 | Hovered error buttons |
--color-error on --color-background | 4.5:1 | Error text: messages, field errors, invalid borders |
--color-accent-foreground on --color-accent | 4.5:1 | Solid accent buttons and badges |
--color-accent-foreground on --color-accent-hover | 4.5:1 | Hovered accent buttons |
--color-accent on --color-background | 4.5:1 | Accent text: messages |
--color-primary on --color-primary at 10% over --color-background | 4.5:1 | Primary text on its 10% tint: soft badges and messages, hovered text and outlined buttons, selected toggles |
--color-info on --color-info at 10% over --color-background | 4.5:1 | Info text on its 10% tint: soft badges and messages, hovered text and outlined buttons |
--color-success on --color-success at 10% over --color-background | 4.5:1 | Success text on its 10% tint: soft badges and messages, hovered text and outlined buttons |
--color-warning on --color-warning at 10% over --color-background | 4.5:1 | Warning text on its 10% tint: soft badges and messages, hovered text and outlined buttons |
--color-error on --color-error at 10% over --color-background | 4.5:1 | Error text on its 10% tint: soft badges and messages, hovered text and outlined buttons |
--color-accent on --color-accent at 10% over --color-background | 4.5:1 | Accent text on its 10% tint: soft badges and messages |
--color-primary-hover on --color-primary at 15% over --color-background | 4.5:1 | Pressed primary text and outlined buttons (the text takes the -hover token), hovered selected toggles |
--color-info-hover on --color-info at 15% over --color-background | 4.5:1 | Pressed info text and outlined buttons (the text takes the -hover token) |
--color-success-hover on --color-success at 15% over --color-background | 4.5:1 | Pressed success text and outlined buttons (the text takes the -hover token) |
--color-warning-hover on --color-warning at 15% over --color-background | 4.5:1 | Pressed warning text and outlined buttons (the text takes the -hover token) |
--color-error-hover on --color-error at 15% over --color-background | 4.5:1 | Pressed error text and outlined buttons (the text takes the -hover token) |
--color-border-control on --color-background | 3:1 | Form control boundaries: inputs, triggers, unchecked checkbox and radio, off switch |
--color-primary on --color-muted | 3:1 | Slider range, progress bar, knob and meter fills on muted tracks |
--color-primary on --color-subtle | 3:1 | Selection indicators on subtle rows and hovered items |
--color-primary on --color-app | 3:1 | Focus rings around controls on the app canvas |
--color-rating on --color-background | 3:1 | Filled rating icons |
--color-rating on --color-muted | 3:1 | Filled rating icons on muted surfaces |
Color tokens
Swatches are live: they follow the theme switch. The numeric scales (--color-primary-50 … -950, --color-surface-*, --color-viz-1 … -8) are primitives and keep their values in both schemes.
| Token | Default | Dark | Purpose |
|---|---|---|---|
--color-background | #ffffff | yes | Component surfaces (cards, panels, inputs, overlays) |
--color-foreground | #151a24 | yes | Primary text on background |
--color-app | #f7f8fa | yes | App canvas behind surfaces |
--color-subtle | #eff1f5 | yes | Lightest neutral fill (hover rows, wells) |
--color-muted | #e6e9ef | yes | Neutral fill (tracks, skeletons, disabled fields) |
--color-foreground-soft | #4b5263 | yes | Secondary text |
--color-muted-foreground | #626a7a | yes | Hints, placeholders, meta text |
--color-disabled | #9aa2b1 | yes | Disabled text and icons |
--color-link | #1f49c7 | yes | Inline link text |
--color-border-subtle | #e6e9ef | yes | Dividers inside surfaces |
--color-border | #dce0e8 | yes | Default surface border |
--color-border-strong | #c3c9d5 | yes | Decorative and emphasised edges (panels, secondary buttons) |
--color-border-control | #6b7384 | yes | Form control boundaries: ≥3:1 non-text contrast |
--color-primary | #2b5ce6 | yes | Brand color: primary buttons, selection, focus rings |
--color-secondary | #eff1f5 | yes | Secondary (neutral) buttons and chips |
--color-info | #2b5ce6 | yes | Informational status |
--color-success | #11754f | yes | Success status |
--color-warning | #945806 | yes | Warning status |
--color-error | #be3037 | yes | Error status, invalid fields, destructive actions |
--color-accent | #7c3aed | yes | Violet for passive indicators (badges and chips only) |
--color-backdrop | rgb(0 0 0 / 0.5) | Dialog and drawer backdrop |
Radii
Each component has its own radius token, so you can round buttons without rounding cards.
| Token | Default | Dark | Purpose |
|---|---|---|---|
--radius-button | 0.375rem | Buttons, select and toggle buttons, paginator, stepper | |
--radius-input | 0.375rem | Text fields, selects, file drop zone | |
--radius-popover | var(--radius-input) | Popover and date picker panels | |
--radius-menu | var(--radius-input) | Menus and the option panels of select, multi-select and autocomplete | |
--radius-card | 0.5rem | Cards | |
--radius-dialog | 0.5rem | Dialogs and drawers | |
--radius-chip | 0.25rem | Chips | |
--radius-badge | calc(infinity * 1px) | Badges (pill) | |
--radius-checkbox | 0.25rem | Checkboxes | |
--radius-switch | calc(infinity * 1px) | Toggle switch track and thumb | |
--radius-slider | calc(infinity * 1px) | Slider track | |
--radius-tooltip | 0.375rem | Tooltips | |
--radius-message | 0.375rem | Messages and toasts | |
--radius-table | 0.375rem | Table frame | |
--radius-progress | calc(infinity * 1px) | Progress bar track | |
--radius-skeleton | 0.25rem | Skeleton blocks | |
--radius-avatar | 0.375rem | Square avatars | |
--radius-link | 0.125rem | Link focus outline |
Focus rings
Focus comes in three shapes: the --shadow-focus halo on bordered text-entry controls and buttons, the offset --shadow-focus-ring on borderless and non-text controls, and the currentColor ring inside tinted surfaces. They derive from --color-primary, --color-error and --color-background, so a rebrand recolors them. Use them in your own controls as focus-visible:shadow-(--shadow-focus-ring).
--shadow-focus--shadow-focus-error--shadow-focus-ring--shadow-focus-ring-error--shadow-focus-current
| Token | Default | Dark | Purpose |
|---|---|---|---|
--shadow-focus | 3px primary halo | yes | Halo on bordered text-entry controls and buttons |
--shadow-focus-error | 3px error halo | yes | Halo on invalid text-entry controls |
--shadow-focus-ring | 2px offset + 2px primary | yes | Offset ring on borderless and non-text controls |
--shadow-focus-ring-error | 2px offset + 2px error | yes | Offset ring on invalid checkboxes, switches and radios |
--shadow-focus-current | 0 0 0 2px currentColor | Ring inside tinted surfaces (chip remove, message close) |
Motion
Durations have no utility namespace: use duration-(--duration-fast). Spinners, progress bars and skeletons fall back to static visuals under prefers-reduced-motion.
| Token | Default | Dark | Purpose |
|---|---|---|---|
--ease-standard | cubic-bezier(0.2, 0, 0, 1) | Default curve for state changes | |
--ease-out | cubic-bezier(0.16, 1, 0.3, 1) | Entering elements | |
--ease-in | cubic-bezier(0.4, 0, 1, 1) | Leaving elements | |
--duration-fast | 120ms | Tooltips, popovers, switches | |
--duration-base | 180ms | Dialogs, accordions, toasts, floating labels | |
--duration-slow | 260ms | Drawers |
Global side effects
Importing theme.css redefines some Tailwind defaults app-wide because the components rely on them: --text-base, --text-sm, --text-xs (a denser 14 / 13 / 12px scale), --font-sans, --font-mono, the --shadow-* scale and --ease-in / --ease-out. To keep Tailwind's values, restore them in your @theme; the kit then uses them too.
@theme {
--font-sans: ui-sans-serif, system-ui, sans-serif;
--text-sm: 0.875rem;
--text-sm--line-height: calc(1.25 / 0.875);
--text-base: 1rem;
--text-base--line-height: calc(1.5 / 1);
/* …and likewise for the other values you rely on */
}