Vertz provides a built-in styling system based on design tokens. No CSS files, no class name collisions, no build-step CSS tooling. You write styles in TypeScript and get scoped class names at runtime.
css() — scoped styles
Create a group of scoped styles with css() and the token helper:
Each key in the object becomes a scoped class name. CSS property names use camelCase (backgroundColor, borderRadius). The token helper resolves to CSS custom properties from your theme.
Token helper
The token namespace is typed against your active theme. Use dot notation for camelCase token names and bracket notation for any token name that contains a hyphen or a shade number.
| Expression | CSS output |
|---|
token.color.card | var(--color-card) |
token.color.foreground | var(--color-foreground) |
token.color['muted-foreground'] | var(--color-muted-foreground) |
token.color.primary[600] | var(--color-primary-600) |
token.spacing[4] | var(--spacing-4) |
token.font.size.lg | var(--font-size-lg) |
token.font.weight.bold | var(--font-weight-bold) |
token.radius.lg | var(--radius-lg) |
Raw CSS keywords like 'flex', 'center', '100%', 'inherit', or 'transparent' are passed through literally.
The full token set comes from your theme (@vertz/theme-shadcn or a custom theme defined with defineTheme()).
Shade color tokens
Color palettes support a full shade scale beyond the semantic tokens. Use bracket notation for the numeric shade:
Available namespaces — these are the color namespaces that support shade notation:
| Namespace | Example | CSS output |
|---|
primary | token.color.primary[600] | background-color: var(--color-primary-600) |
secondary | token.color.secondary[400] | color: var(--color-secondary-400) |
accent | token.color.accent[100] | background-color: var(--color-accent-100) |
gray | token.color.gray[500] | color: var(--color-gray-500) |
destructive | token.color.destructive[600] | background-color: var(--color-destructive-600) |
danger | token.color.danger[500] | color: var(--color-danger-500) |
success | token.color.success[100] | background-color: var(--color-success-100) |
warning | token.color.warning[300] | border-color: var(--color-warning-300) |
info | token.color.info[50] | background-color: var(--color-info-50) |
muted | token.color.muted[600] | color: var(--color-muted-600) |
surface | token.color.surface[100] | background-color: var(--color-surface-100) |
Shade scale — each namespace supports shades from 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 selectors
Use nested &: selectors to apply styles on pseudo-states:
variants() — parameterized styles
Use variants() for components with multiple visual states:
Use it in JSX by calling the function with variant values:
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 (
display: 'flex', padding: token.spacing[4], gap: token.spacing[2])
- Sizing (
width: '100%', height: '100vh') and aspect ratios (aspectRatio: '16 / 9')
- Positioning (
position: 'absolute', top: 0, left: token.spacing[4], inset: 0)
- Images (
objectFit: 'cover', objectFit: 'contain')
- Typography scales (
fontSize: token.font.size.lg, fontWeight: token.font.weight.semibold)
- Borders and radius (
borderWidth: '1px', borderColor: token.color.border, borderRadius: token.radius.lg)
- Colors from the theme/shade system (
backgroundColor: token.color.primary[600], color: token.color.gray[500])
- Pseudo-states (
&:hover, &:focus, &:disabled)
Use inline 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 with defineTheme():
Global styles
For reset styles or global base rules, use globalCss():
Global styles are injected once and aren’t scoped — use sparingly.
Fonts
Declare font families with font() and compile them into @font-face CSS, custom properties (--font-<key>), and preload tags with compileFonts(). Only woff2 format is supported.
Reference the generated CSS vars in components:
Multiple font files
Pass an array of src entries for variants like normal + italic:
Each entry generates a separate @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:
Google Fonts
Use googleFont() to declare a Google Font by name. The framework automatically fetches the .woff2 file at dev/build time, caches it locally, and serves it self-hosted. No manual downloads needed.
That’s the complete setup. The dev server handles everything else:
- Fetches the font from Google Fonts CSS2 API on first startup
- Downloads the
.woff2 file to .vertz/fonts/ (cached across restarts)
- Generates
@font-face CSS with the local file path
- Computes zero-CLS fallback metrics automatically
- Injects
<link rel="preload"> tags in SSR
googleFont() options:
| Option | Type | Default | Description |
|---|
weight | string | number | number[] | (required) | Weight range ('100..900'), single weight (400), or multiple ([400, 700]) |
style | 'normal' | 'italic' | ('normal' | 'italic')[] | 'normal' | Font style(s) |
display | 'auto' | 'block' | 'swap' | 'fallback' | 'optional' | 'swap' | font-display strategy |
subsets | string[] | ['latin'] | Character subsets |
fallback | string[] | auto-detected | Fallback font stack |
adjustFontFallback | boolean | true | Enable zero-CLS metric-adjusted fallback |
Static font with specific weights:
Using font() alongside googleFont():
font() and googleFont() return the same FontDescriptor type and can be mixed freely in themes:
Google Fonts are all open-source licensed (SIL OFL or Apache 2.0). Self-hosting is explicitly
permitted.
Offline and CI caching
Font files are cached in .vertz/fonts/ and persist across dev server restarts. For CI environments without network access, cache this directory:
If the cache is empty and no network is available, the dev server logs an error and falls back to system fonts.