token-workflow
Token Workflow
Non-negotiable Rule
Every new --sgds-* design token requires ALL THREE deliverables — never partial:
src/css/utility.css— Tailwind custom property mappingplayground/utility/[name].html— Live HTML demostories/utilities/[name].stories.js— Storybook story
Token Architecture
src/themes/root.css Primitive tokens — base values, no theme variation
↓
src/themes/day.css + night.css Semantic mappings — theme-aware, references primitives
↓
src/css/utility.css Tailwind @theme — generates sgds: utility classes
Checklist: Adding New Tokens
- Add primitive tokens to
root.css(if new primitives needed) - Add semantic mappings to both
day.cssandnight.css - Add Tailwind custom property to
src/css/utility.css - Create
playground/utility/[name].htmlpreview - Run
pnpm run utility:devand test light/dark theme toggle - Create
stories/utilities/[name].stories.jsstory - Run
pnpm storybookto verify display
Checklist: Renaming a Semantic Token
Update all five layers in one commit:
-
day.css+night.css— rename token definition -
src/css/utility.css— rename custom property and its reference -
playground/css/utility.css— rename CSS variable mapping and.sgds\:class -
playground/utility/*.html— update table cell, CSS variable cell, utility class on preview div, and label text -
stories/utilities/*.stories.js— updateColorItem(...)call with new token name and variable
Storybook Introduction Pattern
stories/utilities/[category]/introduction.mdx → docs/[Category].md
import { Meta, Markdown } from "@storybook/blocks";
import Docs from "../../../docs/Category.md?raw";
<Meta title="Utilities/Category/Introduction" />
<Markdown>{Docs}</Markdown>
Commands
| Command | Purpose |
|---|---|
pnpm run utility:dev |
Tailwind watches playground/utility/*.html for class generation |
pnpm run dev |
Preview playground files in browser |
pnpm storybook |
Preview Storybook |
pnpm test |
Run unit tests |
pnpm build |
Build to lib/ |
- tailwind-mapping - For detailed Tailwind v4 CSS variable conversion rules and playground documentation
More from govtechsg/sgds-web-component
sgds-components
Complete reference for all SGDS web components including installation and framework integration. Use when users ask about any <sgds-*> component — accordion, alert, badge, breadcrumb, button, card, checkbox, close-button, combo-box, datepicker, description-list, divider, drawer, dropdown, file-upload, footer, icon, icon-button, icon-card, icon-list, image-card, input, link, mainnav, masthead, modal, overflow-menu, pagination, progress-bar, quantity-toggle, radio, select, sidebar, sidenav, skeleton, spinner, stepper, subnav, switch, system-banner, tab, table, table-of-contents, textarea, thumbnail-card, toast, or tooltip. Also covers React 19+, React ≤18, Vue, Angular, and Next.js integration.
58sgds-theming
Customising the visual theme of an SGDS application — product brand colours, day/night mode, and font. Use when users ask about changing the primary colour, theming their app, enabling dark mode, night mode, overriding CSS tokens, or customising the font. Apply this skill whenever theming, branding, or CSS token overrides are mentioned.
55sgds-workflow
ALWAYS use this skill when building UI with @govtechsg/sgds-web-component or when a user mentions SGDS or Singapore Design System — even if they don't explicitly ask for help. This is the mandatory entry point for all SGDS development: it guides you to the right skill for setup, components, utilities, forms, theming, page layouts, block templates, and data visualisation. Read this before writing any SGDS application code.
53sgds-data-visualisation
Use this skill when users ask about data visualisation, charts, graphs, or dashboards in an SGDS application. Covers ECharts setup and applying the SGDS colour palette to charts.
53sgds-forms
Use this skill when users ask about form validation in SGDS, hasFeedback prop, constraint validation, custom validation, noValidate, setInvalid, form submission, or reading FormData from SGDS form components.
53sgds-getting-started
Starting point for any new application built with the SGDS web component library. Apply this skill first whenever a user is bootstrapping a new SGDS project, setting up a new app, or asking where to begin with SGDS. Covers font setup, foundation CSS, utilities, components, and app layout in the correct order.
53