This is a deliberately small but complete Vite + React + TypeScript application. DTCG tokens are
the single source of truth: tokenc generates both CSS Custom Properties and TypeScript constants,
which React consumes for presentation and counter behavior respectively.
From the repository root:
vp install
vp -C examples/react-counter run check:tokens
vp -C examples/react-counter run devOpen the local URL printed by the terminal. The page increments, decrements, and resets the counter, and switches between light and dark themes. To create a production build:
vp -C examples/react-counter run buildBoth dev and build regenerate token artifacts first. To rebuild continuously while editing
tokens, run this in a second terminal:
vp -C examples/react-counter run tokens:watchtokens/*.json
│ DTCG tokens, aliases, and theme Context
▼
tokenc.config.ts
├── CSS backend ─────► src/generated/tokens.css ─► styles.css
└── TypeScript backend ► src/generated/tokens.ts ─► App.tsx
tokens/foundation.jsondefines raw colors, spacing, radii, motion, and the counter range.tokens/semantic.jsoncreates the semantic alias layer and usesorg.token-compiler.contextsfor dark-theme overrides.tokens/component.jsonmaps semantic tokens to the app and its controls.tokenc.config.tsmapstheme=light/darkto CSS selectors and enables flat TypeScript output.src/generated/tokens.cssis consumed by styles, for examplevar(--counter-panel-background).src/generated/tokens.tsis imported by React, for examplecounterStep.src/theme.tsxonly changes the DOMdata-theme; the actual values come from generated CSS.
Generated files are intentionally committed for inspection and diffing. Do not maintain them by
hand; rebuild them with vp -C examples/react-counter run tokens.
Install the VSIX, then open this example itself as the workspace:
vp -C packages/vscode-extension run package:vsix
code --install-extension artifacts/tokenc-vscode.vsix --force
code examples/react-counterThe install command installs the extension but does not open a window. Trust the new workspace;
the included .vscode/settings.json already defines light and dark Context profiles.
Try each feature:
- Open
tokens/semantic.jsonand hover over{palette.slate.50}to inspect its type, expression, resolved value, Context, and provenance. - Press
F12on the alias to jump to its definition; useShift+F12to list all references. - Put the cursor after an alias
{and pressCtrl+Space(or run Trigger Suggest) for sorted Token ID completions. - Open Explorer's Outline for the document token hierarchy; press
Cmd+T(Ctrl+Ton Windows/Linux) to search workspace tokens. - Press
F2on the declaration or a reference tosurface.muted, and enter the complete IDsurface.subtle. The declaration and every token alias are renamed atomically. Runvp -C examples/react-counter run tokensafterward to refresh generated files, then undo if you only wanted to experiment. - Temporarily change an alias to
{missing.token}. Observe Problems and the inline diagnostic; restore valid content and the diagnostic disappears with the current snapshot. - Run tokenc: Select Context Profile → Dark, then hover
canvas.backgroundagain. The resolved value changes to the dark Context. This editor-only query does not write files or control the browser theme. - Run tokenc: Show Language Server Status to inspect lifecycle and trust, or tokenc: Restart Language Server when a reload is needed.
See the complete VS Code guide for every feature, setting, multi-root behavior, and troubleshooting.
| Command | Purpose |
|---|---|
vp -C examples/react-counter run tokens |
Generate CSS and TypeScript |
vp -C examples/react-counter run check:tokens |
Validate tokens without writing files |
vp -C examples/react-counter run tokens:watch |
Watch tokens and regenerate incrementally |
vp -C examples/react-counter run dev |
Generate tokens and start the Vite dev server |
vp -C examples/react-counter run build |
Generate tokens and build the production site |