css() — scoped styles
Create a group of scoped styles with css():
bg:card, font:lg, rounded:lg) maps to design tokens from your theme.
Token syntax
Tokens follow the patternproperty:value:
| Token | CSS output |
|---|---|
bg:card | background-color: var(--color-card) |
text:foreground | color: var(--color-foreground) |
font:lg | font-size: 1.125rem |
font:bold | font-weight: 700 |
rounded:lg | border-radius: 0.5rem |
p:4 | padding: 1rem |
px:4 | padding-inline: 1rem |
flex | display: flex |
items:center | align-items: center |
gap:2 | gap: 0.5rem |
@vertz/theme-shadcn or a custom theme defined with defineTheme()).
Shade color tokens
Color properties (bg, text, border) support shade tokens using dot notation: namespace.shade. This gives you access to a full color scale beyond the semantic tokens.
| Namespace | Example | CSS output |
|---|---|---|
primary | bg:primary.600 | background-color: var(--color-primary-600) |
secondary | text:secondary.400 | color: var(--color-secondary-400) |
accent | bg:accent.100 | background-color: var(--color-accent-100) |
gray | text:gray.500 | color: var(--color-gray-500) |
destructive | bg:destructive.600 | background-color: var(--color-destructive-600) |
danger | text:danger.500 | color: var(--color-danger-500) |
success | bg:success.100 | background-color: var(--color-success-100) |
warning | border:warning.300 | border-color: var(--color-warning-300) |
info | bg:info.50 | background-color: var(--color-info-50) |
muted | text:muted.600 | color: var(--color-muted-600) |
surface | bg:surface.100 | background-color: var(--color-surface-100) |
50 (lightest) to 950 (darkest):
50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950
The actual color values are defined by your theme. When using palettes from @vertz/ui/css, the Tailwind v4 oklch color palettes are available (slate, gray, zinc, neutral, stone, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose).
Using palettes in your theme:
Pseudo-state tokens
Use nested selector objects to apply styles on pseudo-states:variants() — parameterized styles
Use variants() for components with multiple visual states:
Reactive variants
Variant values can be reactive — the class name updates automatically when the signal changes:When to use css() vs inline styles
Use css() for:
- Layout and spacing (
flex,grid,p:4,gap:2) - Sizing (
w:full,h:screen,max-w:lg) - Typography scales (
font:lg,font:semibold,text:sm) - Borders and radius (
border:1,border:border,rounded:lg) - Colors from the theme/shade system (
bg:primary.600,text:gray.500) - Pseudo-states (
&:hover,&:focus,&:disabled)
style for:
- Truly dynamic values computed at runtime (
transform,translate) - Syntax highlight colors or external color values
- Complex CSS that has no token equivalent (gradients,
clamp(),backdrop-filter) - Custom shadows beyond the shadow scale
- CSS custom property references (
var(--my-custom-prop))
Theme
Vertz uses CSS custom properties for theming. The@vertz/theme-shadcn package provides a shadcn/ui-inspired token set with light and dark mode support.
Custom themes
Define your own theme withdefineTheme():
Global styles
For reset styles or global base rules, useglobalCss():
Fonts
Declare font families withfont() and compile them into @font-face CSS, custom properties (--font-<key>), and preload tags with compileFonts(). Only woff2 format is supported.
Multiple font files
Pass an array ofsrc entries for variants like normal + italic:
@font-face block. Only the first file is preloaded.
System fonts (no src)
Omit src to generate a CSS custom property without an @font-face block: