Design System
Nilakan’s home page, documentation, and playground use @nlk/ui. The logo’s blue carries links,
actions, and the header. Brass identifies primed values: the next state of a loop. The planetary
illustration follows Nilakantha’s astronomy; the kolam divider loops around a row of dots.
Foundations
Section titled “Foundations”| Source | Responsibility |
|---|---|
src/styles/tokens.css |
Color, type, spacing, radius, shadows, motion, and artwork URLs |
src/palette.ts |
Typed light and dark palettes used by syntax themes |
src/styles/components.css |
Static buttons, wordmark, code, trace, diagnostic, and divider |
src/components and tailwind.css |
React components and their Tailwind token mapping |
src/styles/starlight.css |
Documentation typography and Starlight color mapping |
All paths above are relative to packages/ui. Change the shared tokens before adding a local color,
font, or scale. Keep palette.ts and the CSS color tokens synchronized; the palette tests also
check text and control contrast.
Readability
Section titled “Readability”Nilakan is read by teachers and students of every age, so the system favors legibility over subtlety:
- Every text ink and syntax color reaches WCAG AAA contrast (7:1) on the page and on code cards, in both themes. The links’ brand blue is the one exception and reaches AA.
- Secondary text is not dimmed.
--muted-foregroundand--brand-mutedprint at full ink; hierarchy comes from size and weight. Only input placeholders are lighter, so they never read as typed text. - Nothing reads below 14px:
--text-xsis 14px and--text-smis 16px, and the playground editor sets code at 16px.
The palette and syntax-theme tests enforce the contrast targets.
Manjari is the display and body face, including Malayalam. Chilanka is used for handwritten
quotations. Both come from Swathanthra Malayalam Computing. Code and trace values use Atkinson
Hyperlegible Mono. scripts/fonts.mjs lists the self-hosted subsets and matching local fallbacks.
The build copies those fonts and generates dist/styles/fonts.css; edit the source list rather than
the generated stylesheet. Fonts use font-display: optional: when a face arrives too late for the
first paint, its local fallback stays in use for that page instead of moving visible text.
Components in this theme
Section titled “Components in this theme”These samples use the same classes as the home page and follow the documentation’s theme selector.
Code in another language, set beside Nilakan for comparison, uses nlk-code nlk-code--other: the
same syntax colors on a dashed edge instead of a card. A wrong value can be marked like a teacher’s
correction with nlk-circled, a hand-drawn ring from ring.svg, and a nlk-margin-note in
Chilanka.
The playground uses the shared React components for buttons, menus, command search, dialogs, selects, empty states, and notifications. These components read the same semantic tokens as the static classes. App styles position them and style domain-specific content such as trace rows.
Monaco and TextMate colors come from src/syntax-theme.ts. Update both adapters through that shared
mapping. The editor’s syntax integration tests check that equivalent lexical roles have the same
presentation in the playground and documentation.
A next-state name such as b' prints whole in brass, with its prime in bold, so a reader who misses
the prime still sees that the name changed. Current-state names keep the variable ink. The site
renderer marks the name with nlk-next and the prime with nlk-prime, so both turn to the brand
accent on the brand blue.
Maintaining the assets
Section titled “Maintaining the assets”The SVG illustrations are generated from scripts/art.mjs and scripts/art/lib.mjs. Edit the
drawings there, run the generator, and commit the resulting SVGs in src/styles/art:
pnpm --filter @nlk/ui artThe docs render Run in playground links at build time through
apps/docs/src/expressive-code/runInPlayground.mjs. Keep them in the initial HTML so code fences
retain their height when client scripts load. Font preloads in the docs head and site layout use the
same files as the generated font stylesheet.
After changing shared presentation, run pnpm build:site, pnpm typecheck, pnpm test, and
pnpm format:check. Review the home page, docs, and playground in both themes and at a narrow
viewport. Motion should remain optional under prefers-reduced-motion.