kern is the design system for the tools
The system
kern is the component library and token set behind four of the tools on this site: hexicon, specifi, gray-scott and tokenise. Each tool imports the same sidebar, controls and type, and changes only its accent. The window below is one kern surface as each of them renders it.
/* hexicon/src/index.css */ --primary: var(--color-pulsar); --ring: var(--color-pulsar); --link: var(--color-tidal);
The problem
The tools are separate Vite and React apps, each with its own repository and deployment. Built apart, they drifted: a slightly different button in each, a spacing scale each, a definition of muted text each. text-void-60 appeared 136 times across four codebases, always meaning body text, so one contrast fix meant 44 edits. kern defines the shared parts once, and holds nothing only one tool needs.
Design decisions
Three tiers of tokens. Primitives hold raw values: the void neutral ramp and eleven named accents, each with a dark, base and light stop. Roles name what a value is for (surface-page, ink-body, line), and each generates a Tailwind utility. The accent seam is the third tier. Components read roles and the seam, never a named colour.
text-(--primary)atoms/Button.tsx--primary: var(--color-pulsar)--color-pulsar: #7193EDOne accent seam. --primary, --ring and --link default to pulsar. A tool redefines them in its own index.css, and every active row, filled track, selected chip and focus ring follows, as the first window shows. Nothing forks. The Figma file draws the same seam: its roles collection has a mode per tool, so switching mode retints every component the way a tool's index.css does.
/* tier 1: primitives, raw values */
--color-void-0: #121213; /* … through --color-void-90 */
--color-pulsar: #7193ED; /* … 11 accents, each dark / base / light */
/* tier 2: roles a component reads */
--surface-page, --surface-panel, --ink-body, --line …
/* tier 3: the accent seam a tool overrides */
:root {
--primary: var(--color-pulsar);
--ring: var(--color-pulsar);
--link: var(--color-pulsar);
}A ramp with two zones. Steps 0 to 30 are surfaces and sit close together, because an elevation step should be small. Steps 50 to 90 carry text. Step 40 is 2.60:1 on the page, so it is named line-strong and given no ink role.
0page101.1201.3301.6402.6506.0608.77012.58014.59016.6Type by role. Each role carries its own size, weight, line height and tracking, with a .type-* class per role, and may only declare a weight Parkinsans ships. h1 and h2 once declared weight 100, which the font does not have, and the browser silently drew 300.
- size
- fluid
- weight
- 800
- line height
- 0.95
- tracking
- -0.03em
Motion as tokens. Five easings and six durations, each named for its case: decelerate for something entering, accelerate for something leaving. --duration-reduced is 0s, so honouring reduced motion is a token swap.
Reduced motion is on, so the dot holds still: --duration-reduced is 0s.
- --ease-decelerate
- cubic-bezier(0, 0, 0.2, 1)
- --duration-enter
- 0.4s
Desktop only. These are wide-canvas tools, so the ViewportGate template renders the interface at lg and up and a short notice below it. The switch is lg: and max-lg: in CSS: no resize listener, and no flash of the wrong branch on first paint.
The tiers, the ramp and the type rules are in DESIGN.md.
Components
Four layers, one direction. Sixteen atoms, sixteen molecules, three organisms and three templates, plus ErrorBoundary in utils/. An atom reads tokens only; a molecule may use atoms; an organism both; a template arranges organisms. Lint fails an import that climbs a tier. The organisms and templates arrived in v1, from parts every tool had hand-rolled.
organism: AppSidebara full region of interface; mounts everything below it
One API contract. A component that renders one element extends that element's props, merges className through cn() and takes ref as a prop. Variants come from class-variance-authority, and anything button-shaped composes buttonVariants. Before v1, nine components dropped className and nothing could take a ref.
Accessible, and enforced. One focus ring drawn from --ring, the a11y addon on every story, and axe in every component's tests. An icon-only control requires its aria-label, so a nameless one is a type error. Each ink role names the surfaces it may sit on, and contrast.test.ts holds exactly those pairs to WCAG AA. It replaced a contrast matrix that measured everything and prevented nothing, under which a 2.6:1 label had shipped.
// kern/src/atoms/IconButton.tsx
interface IconButtonProps extends Omit<ButtonProps, "size" | "children"> {
"aria-label": string // required: an icon has no text to name it
}
<IconButton onClick={close}><X /></IconButton> // ✗ type error
<IconButton onClick={close} aria-label="Close"><X /></IconButton> // ✓The layers, the API contract and the accessibility checks are in DESIGN.md.
Engineering
Source, no build. kern ships as TypeScript source with no build step and no npm publish. Its exports map points at src/, so each tool's Vite build compiles kern as its own code, and one @source line lets Tailwind scan it. No dist means no stale dist. Internal imports are relative, so a tool's own @/ alias cannot reach into kern.
"kern": "github:hipuku/kern#v1.5.0"the tag is the version, no npm publishTypeScript source, no build artefact"." → ./src/index.ts@source "../node_modules/kern/src"A public API. The package root and the five layer barrels are the surface; a deep import such as kern/src/atoms/Input fails with ERR_PACKAGE_PATH_NOT_EXPORTED. That let ErrorBoundary move folders without a breaking change.
One token source. src/tokens/tokens.ts holds every value. A script generates the token CSS from it and the Storybook token pages render from the same objects. The CSS is committed, since kern ships as source, and tokens:check fails CI if it is stale.
Each tool pins a tag. Until v1 the tools installed an unpinned github:hipuku/kern, so a routine reinstall could pull a breaking change. Pinned, the v1 rebuild shipped and was adopted one tool at a time. All four are on v1.5.0. No monorepo: a tag gives the same isolation without coupling separate deployments.
Held by CI. CI fails on stale token CSS, an import that climbs a tier, a component without a story, a declared pair below AA, and an axe violation. Each guards a failure that happened once. A parity check also compares every token, tint and component with kern's Figma file on every pull request, and fails when code moves ahead of the design. It started with two things Figma lacked, Button's disabled state and IconButton's link variant; both are now drawn (kern#51).
Distribution, the public API and the checks are in DESIGN.md.
Where it stands
All four tools are on v1.5.0. kern is not on npm because nothing outside these tools uses it. A pattern one tool needs stays in that tool until a second needs it, so some duplication is deliberate.
The design notes are in DESIGN.md.