Tokens
Via Box
Box is the preferred approach. Pass token names directly as props. Box translates them to atomic CSS classes without any manual .css.ts authoring.
<Box padding="large" background="neutralLight" borderRadius="md"> <Text>Token names map directly to atomic CSS classes.</Text></Box>Under the hood
Tokens are plain TypeScript constants consumed by .css.ts files at build time. Vanilla Extract compiles them to static CSS, so the browser receives an ordinary stylesheet and no JavaScript.
export const card = style({ padding: space.large, borderRadius: radius.md, background: vars.backgroundColor.neutralLight,});Compiled output
Token values are inlined at build time. Theme colors stay CSS variables, so themes switch at runtime without a rebuild.
.card_1skp7a2o { padding: 1.25rem; border-radius: 0.375rem; background: var(--backgroundColor-neutralLight__1hqmkoh);}Type safety
Token names are typed as string literal unions. Passing an invalid value is a TypeScript error caught before the browser sees it.
applyPadding('giant'); // Argument of type '"giant"' is not assignable to type 'Space'applyPadding('large');Foreground colors
Semantic text colors from the theme contract, applied with the tone prop on Text. Values follow the active theme.
Background colors
Semantic surface colors from the theme contract, applied with the background prop on Box. Interactive tokens include Hover and Active variants.
Border colors
Semantic border colors from the theme contract.
Focus ring
Focus outline thickness from the theme contract, drawn with the focus border color.
Space
Padding, margin, and gap values in rem, relative to a 16px base.
Border radius
Corner rounding. The full token creates pills and circles.
Font size
Raw size scale consumed by typography styles. Use Text or Heading rather than these tokens directly.
Font weight
Available through the weight prop on Text.
Font family
Sans for interface text, mono for code.
Letter spacing
Available through the letterSpacing prop on Text. Widest suits uppercase labels.
Content width
Widths for constraining containers. A separate scale from space.
Breakpoints
Minimum widths used by responsive props. Mobile is the unprefixed default.
Media queries
Query strings derived from the breakpoints, consumed by .css.ts files.
Border width
Used for borders and for boxShadow borders that avoid layout shift.
Touch target
Minimum touch target size per WCAG 2.5.5 and the Apple Human Interface Guidelines.