A design system built with React, TypeScript and SCSS. It contains design tokens, a stylesheet layer, a React component library, a live showcase page and Storybook docs, all in one Yarn workspaces monorepo.
The packages are private and are not published to npm. Everything runs from this repository.
Requirements: Node.js 20.19 or newer and Yarn 1 (the workspaces setup uses Yarn).
yarn install
yarn startyarn start builds every package once, then runs all of these together:
| What | URL |
|---|---|
| Showcase page (colors, typography, spacing and every component) | http://localhost:3000 (opens automatically) |
| Storybook (component docs, controls and accessibility checks) | http://localhost:6006 |
The showcase header has an Open Storybook button. Leave the command running while you work. Changes to SCSS, components or tokens rebuild automatically and show up in both pages. If port 3000 is busy, the showcase picks the next free port and prints it in the terminal.
ds.ui/
├── packages/
│ ├── foundation/ @ds.ui/foundation: design token names shared with TypeScript
│ ├── scss/ @ds.ui/scss: tokens, CSS variables, base styles and component CSS
│ └── react/ @ds.ui/react: React components, tests and Storybook stories
├── playgrounds/
│ └── react/ @ds.ui/playground-react: the showcase page (Vite)
└── .github/workflows CI: build, tests and Chromatic visual tests
Token names that components use in their TypeScript types, so props like space="md" are type checked.
Spacing:xxxs,xxs,xs,sm,md,lg,xl,xxl,xxxlFontSize:xs,sm,base,lg,xl
All visual styling lives here, separate from React, so the CSS can be used on its own. Every class uses the ds- prefix.
| Folder | Contents |
|---|---|
src/foundation/ |
SCSS tokens: colors, typography, spacing scale, breakpoints and mixins |
src/base/ |
Reset (normalize) and :root CSS custom properties such as --ds-color-primary |
src/atoms/ |
Styles for Badge, Button, Input, Margin, Switch and Typography, plus utility classes |
src/molecules/ |
Styles for Accordion and Tabs |
yarn build compiles src/global.scss and each component file to a matching CSS file in lib/, such as lib/Button.css.
Styling has three layers:
- SCSS tokens (
foundation/_variables.scss): the raw values for colors, type and spacing. - CSS custom properties (
base/_root.scss): tokens exposed at runtime as--ds-*variables, which can be overridden for theming. - Component styles (
atoms/,molecules/): one file per component, built from the tokens.
Utility classes are generated from the spacing scale: ds-margin-{size}, ds-margin-{top|right|bottom|left}-{size}, ds-width-{size} and ds-height-{size}.
React components organized with Atomic Design:
| Component | Type | Highlights |
|---|---|---|
Typography |
Atom | Variants h1–h6, body and caption |
Button |
Atom | primary, secondary and danger variants; accepts all native button attributes |
Input |
Atom | Label linked to the input; errors set aria-invalid and aria-describedby |
Badge |
Atom | default, success, warning and error variants, with optional icon and count |
Switch |
Atom | role="switch"; works controlled (checked) or uncontrolled (defaultChecked) |
Margin |
Atom | Adds spacing from the scale on any side |
Tabs |
Molecule | Arrow keys, Home and End navigate between tabs, and disabled tabs are skipped; controlled or uncontrolled |
Accordion |
Molecule | Keyboard-accessible headers, optional multiple open sections; controlled or uncontrolled |
import { Button, Tabs } from '@ds.ui/react';
import '@ds.ui/scss/lib/global.css';
import '@ds.ui/scss/lib/Button.css';
import '@ds.ui/scss/lib/Tabs.css';Components are bundled with Rollup into lib/ as ES modules with TypeScript declarations. Every component folder that has an index.ts becomes a build entry automatically.
A single page that renders the design system from the compiled packages. It has four sections:
- Colors: every color token with its value.
- Typography: each text variant with its size and weight.
- Spacing: the full scale with measured sizes.
- Components: an interactive demo of each component.
Token values are read from the compiled CSS at runtime, so the page always matches the SCSS.
The Storybook button points to http://localhost:6006 by default. To point it at a deployed Storybook, set VITE_STORYBOOK_URL.
Run these from the repository root:
| Command | What it does |
|---|---|
yarn start |
Builds everything, then runs the showcase and Storybook with all packages in watch mode |
yarn dev |
Watch mode for all packages plus the showcase, without Storybook |
yarn storybook |
Storybook only, with the SCSS watcher |
yarn build |
Builds foundation, scss and react, in that order |
yarn test |
Runs the Jest test suites |
yarn build-storybook |
Builds a static Storybook |
yarn test:chromatic |
Uploads Storybook to Chromatic for visual tests (needs CHROMATIC_PROJECT_TOKEN) |
yarn commit |
Writes a conventional commit message with Commitizen |
- Create
packages/react/src/{atoms|molecules}/Name/withName.tsx,index.ts(export { default } from './Name';),Name.stories.tsxandName.test.tsx. - Export it, and its prop types, from
packages/react/src/index.ts. - Add
packages/scss/src/{atoms|molecules}/Name.scssusingds-classes and the foundation tokens. - Add a demo to
playgrounds/react/src/showcase/Components.tsxand import its CSS inplaygrounds/react/src/index.tsx.
The Rollup build and the SCSS build pick up the new files automatically.
- Unit tests: Jest and React Testing Library, including keyboard and ARIA behavior.
- Accessibility: the Storybook a11y addon checks each story.
- Visual regression: Chromatic runs in CI on every push and pull request to
main. - Commits: follow Conventional Commits, enforced by commitlint. A Husky pre-commit hook runs the tests.