lldlab-ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,909 @@
1
+ # lldlab-ui
2
+
3
+ Design-system components for [LLD Lab](https://lldlab.com), built for React 19 and Tailwind CSS v4.
4
+
5
+ - **Design tokens:** colour, spacing and type come from the LLD Lab Stitch design. Display and headline sizes and page gutters scale fluidly with the viewport.
6
+ - **Responsive by default:** layout props accept one value per breakpoint, and every component is checked for horizontal overflow at 390, 768, 1024 and 1440 px.
7
+ - **Light and dark scopes:** wrap any subtree in `<Theme tone="dark">`.
8
+ - **Accessible:** keyboard support and ARIA semantics follow the WAI-ARIA Authoring Practices, and every story is checked with axe.
9
+ - **No styling escape hatch:** components don't accept `className` or `style`. All visual variation goes through typed props.
10
+
11
+ ---
12
+
13
+ ## Contents
14
+
15
+ - [Install](#install)
16
+ - [Setup](#setup)
17
+ - [Core concepts](#core-concepts)
18
+ - [Components](#components)
19
+ - [Layout](#layout): Theme, Box, Stack, Grid, Container, Section, Split
20
+ - [Typography](#typography): Text, Heading, Eyebrow, Code, CodeBlock, Markdown
21
+ - [Display](#display): Icon, Dot, Badge, Chip, Stat, ProgressBar, SectionHeader, Callout, ResultRow, Message, EmptyState, CheckList, Card
22
+ - [Inputs and interaction](#inputs-and-interaction): Button, IconButton, Kbd, TextField, Select, Tabs, SegmentedControl, Dialog, Menu
23
+ - [IDE shell](#ide-shell): Workbench, FileTree, EditorTabs, Breadcrumbs, StatusBar, MetricTile, Avatar, Countdown
24
+ - [Design tokens](#design-tokens)
25
+ - [Accessibility](#accessibility)
26
+ - [Troubleshooting](#troubleshooting)
27
+ - [Development](#development)
28
+ - [Releasing](#releasing)
29
+
30
+ ---
31
+
32
+ ## Install
33
+
34
+ ```bash
35
+ npm install lldlab-ui
36
+ ```
37
+
38
+ | Requirement | Version |
39
+ |---|---|
40
+ | `react`, `react-dom` (peer dependencies) | 19 |
41
+ | Tailwind CSS in the app | v4 |
42
+
43
+ The package is ESM-only and ships TypeScript types.
44
+
45
+ ## Setup
46
+
47
+ ### 1. Styles
48
+
49
+ Add these three lines to the app's global stylesheet, for example `app/globals.css`:
50
+
51
+ ```css
52
+ @import "tailwindcss";
53
+ @import "lldlab-ui/theme.css";
54
+ @source "../node_modules/lldlab-ui/dist";
55
+ ```
56
+
57
+ - `lldlab-ui/theme.css` defines the design tokens (`--color-*`, `--spacing-*`, `--text-*`), the dark and light scopes, and three utilities: `bg-pattern-dots`, `bg-pattern-grid` and `icon-filled`.
58
+ - `@source` tells the app's Tailwind to scan the library's compiled components. The library ships Tailwind class names, not CSS, so the app generates exactly the classes the components use from the same tokens.
59
+ - **Resolve the `@source` path relative to the CSS file.** If the stylesheet is at `src/app/globals.css`, use `@source "../../node_modules/lldlab-ui/dist";`.
60
+
61
+ Recommended base styles, in the same file:
62
+
63
+ ```css
64
+ body {
65
+ background: var(--color-surface);
66
+ color: var(--color-on-surface);
67
+ font-family: var(--font-inter), system-ui, sans-serif;
68
+ -webkit-font-smoothing: antialiased;
69
+ }
70
+ ```
71
+
72
+ ### 2. Fonts
73
+
74
+ The library reads three CSS variables. The app loads the fonts and sets them:
75
+
76
+ | Variable | Font | Used for |
77
+ |---|---|---|
78
+ | `--font-space-grotesk` | Space Grotesk | display text and headlines |
79
+ | `--font-inter` | Inter | body text and buttons |
80
+ | `--font-jetbrains-mono` | JetBrains Mono | labels, code and timers |
81
+
82
+ With Next.js:
83
+
84
+ ```tsx
85
+ // app/layout.tsx
86
+ import { Inter, JetBrains_Mono, Space_Grotesk } from 'next/font/google';
87
+ import './globals.css';
88
+
89
+ const inter = Inter({ subsets: ['latin'], variable: '--font-inter' });
90
+ const grotesk = Space_Grotesk({ subsets: ['latin'], variable: '--font-space-grotesk' });
91
+ const mono = JetBrains_Mono({ subsets: ['latin'], variable: '--font-jetbrains-mono' });
92
+
93
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
94
+ return (
95
+ <html lang="en" className={`${inter.variable} ${grotesk.variable} ${mono.variable}`}>
96
+ <head>
97
+ <link
98
+ rel="stylesheet"
99
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,400,0..1,0&display=block"
100
+ />
101
+ </head>
102
+ <body>{children}</body>
103
+ </html>
104
+ );
105
+ }
106
+ ```
107
+
108
+ ### 3. Icons
109
+
110
+ `Icon` and every component that takes an `icon` prop render [Material Symbols Outlined](https://fonts.google.com/icons) by ligature. Load the font once, as in the `<link>` above, and pass icon names such as `"play_arrow"`, `"check_circle"` or `"search"`.
111
+
112
+ ### 4. Use it
113
+
114
+ ```tsx
115
+ import { Button, Card, Grid, Heading, Stack, Text } from 'lldlab-ui';
116
+
117
+ export function Example() {
118
+ return (
119
+ <Stack gap="lg">
120
+ <Heading level={1} size="display">Master low-level design</Heading>
121
+ <Grid cols={{ base: 1, md: 2, xl: 3 }}>
122
+ <Card>
123
+ <Heading level={3} size="sm">Singleton</Heading>
124
+ <Text tone="muted">One instance, global access.</Text>
125
+ <Button icon="play_arrow">Start</Button>
126
+ </Card>
127
+ </Grid>
128
+ </Stack>
129
+ );
130
+ }
131
+ ```
132
+
133
+ The bundle starts with `'use client'`, so any component can be imported from a Next.js server component. Event-handler props still need a client component, as usual.
134
+
135
+ ---
136
+
137
+ ## Core concepts
138
+
139
+ ### No `className`, no `style`
140
+
141
+ No component accepts `className` or `style`, and TypeScript rejects them. To change how something looks:
142
+
143
+ 1. Use an existing variant prop (`tone`, `variant`, `size`, `padding` and so on).
144
+ 2. If none fits, add a variant or a new component to this library.
145
+
146
+ This keeps every visual decision in one place, so pages stay pure composition.
147
+
148
+ ### Passing through native props
149
+
150
+ Apart from `className` and `style`, most components forward the props of their root element: `id`, `aria-*`, `data-*`, event handlers and `ref`. For example, `<TextField>` forwards every `<input>` prop, and `<Button>` forwards every `<button>` prop.
151
+
152
+ ### `as`: render a different element or component
153
+
154
+ Components marked **polymorphic** below take an `as` prop, which changes the rendered element or plugs in a router link:
155
+
156
+ ```tsx
157
+ import Link from 'next/link';
158
+
159
+ <Button as={Link} href="/problems" iconRight="arrow_forward">Browse problems</Button>
160
+ <Card as={Link} href="/problem/singleton" interactive>…</Card>
161
+ <Stack as="ul" gap="xs">…</Stack>
162
+ <Text as="span" variant="label">New</Text>
163
+ ```
164
+
165
+ When `as` is set, the component accepts that element's or component's props (for example `href` for a link).
166
+
167
+ ### Responsive props
168
+
169
+ Props typed `Responsive<T>` accept either one value or one value per breakpoint (min-width, as in Tailwind):
170
+
171
+ ```tsx
172
+ <Stack direction={{ base: 'column', md: 'row' }} gap={{ base: 'sm', lg: 'lg' }} />
173
+ <Grid cols={{ base: 1, md: 2, xl: 4 }} />
174
+ <Heading level={1} size={{ base: 'lg', md: 'display' }} />
175
+ ```
176
+
177
+ | Breakpoint | Min width |
178
+ |---|---|
179
+ | `base` | 0 |
180
+ | `sm` | 640px |
181
+ | `md` | 768px |
182
+ | `lg` | 1024px |
183
+ | `xl` | 1280px |
184
+
185
+ Sensible collapsing is built in. `Grid` is one column below `md` unless you set `base`. `Split` stacks its aside below `xl`. `Tabs` and `EditorTabs` scroll sideways instead of wrapping. Below `md`, interactive controls grow to at least 44px tall for touch.
186
+
187
+ ### Shared value types
188
+
189
+ These types are exported from the package.
190
+
191
+ | Type | Values |
192
+ |---|---|
193
+ | `Space` | `none` (0) · `2xs` (0.125rem) · `xs` (0.25rem) · `sm` (0.5rem) · `md` (1rem) · `lg` (1.5rem) · `xl` (2.5rem) · `2xl` (4rem) |
194
+ | `Direction` | `row` · `column` |
195
+ | `Align` | `start` · `center` · `end` · `stretch` · `baseline` |
196
+ | `Justify` | `start` · `center` · `end` · `between` |
197
+ | `Cols` | `1` – `6` |
198
+ | `HeadingSize` | `display` · `xl` · `lg` · `md` · `sm` |
199
+ | `Tone` (text and icons) | `default` · `muted` · `strong` · `brand` · `success` · `warning` · `danger` · `inverse` |
200
+ | `StatusTone` (dots, eyebrows, section headers) | `neutral` · `brand` · `success` · `warning` · `danger` |
201
+ | `SurfaceTone` (backgrounds) | `surface` · `subtle` · `elevated` · `low` · `inverse` |
202
+ | `BadgeTone` | `neutral` · `brand` · `success` · `warning` · `danger` · `info` |
203
+ | `ButtonVariant` | `primary` · `secondary` · `subtle` · `ghost` · `danger` |
204
+
205
+ ### Light and dark scopes
206
+
207
+ ```tsx
208
+ <Theme tone="dark">
209
+ <Workbench … /> {/* everything inside uses the dark palette */}
210
+ <Theme tone="light">…</Theme> {/* nested scopes reset */}
211
+ </Theme>
212
+ ```
213
+
214
+ Components use semantic tokens only, so every component works in both scopes. A `Dialog` renders in a portal, and still takes the theme of the element that opened it.
215
+
216
+ ---
217
+
218
+ ## Components
219
+
220
+ In the tables, **Req.** marks required props, and the default is given where one exists. Every component also forwards the native props of its root element, except `className` and `style`.
221
+
222
+ ### Layout
223
+
224
+ #### `Theme`
225
+
226
+ Scopes the colour tokens for its subtree. Polymorphic, default `div`.
227
+
228
+ | Prop | Type | Default |
229
+ |---|---|---|
230
+ | `tone` | `'light' \| 'dark'` | `'light'` |
231
+ | `as` | element or component | `'div'` |
232
+
233
+ ```tsx
234
+ <Theme tone="dark"><App /></Theme>
235
+ ```
236
+
237
+ #### `Box`
238
+
239
+ A generic surface. Polymorphic, default `div`.
240
+
241
+ | Prop | Type | Default |
242
+ |---|---|---|
243
+ | `padding` | `Responsive<Space>` | none |
244
+ | `tone` | `SurfaceTone` | none (transparent) |
245
+ | `radius` | `'none' \| 'sm' \| 'md' \| 'lg'` | `'none'` |
246
+ | `border` | `'none' \| 'subtle' \| 'strong'` | `'none'` |
247
+ | `shadow` | `'none' \| 'sm' \| 'md'` | `'none'` |
248
+
249
+ ```tsx
250
+ <Box tone="elevated" border="subtle" radius="lg" padding={{ base: 'md', lg: 'lg' }}>…</Box>
251
+ ```
252
+
253
+ #### `Stack`
254
+
255
+ A flex row or column. Polymorphic, default `div`.
256
+
257
+ | Prop | Type | Default |
258
+ |---|---|---|
259
+ | `direction` | `Responsive<Direction>` | `'column'` |
260
+ | `gap` | `Responsive<Space>` | `'md'` |
261
+ | `align` | `Responsive<Align>` | none |
262
+ | `justify` | `Responsive<Justify>` | none |
263
+ | `wrap` | `boolean` | `false` |
264
+
265
+ ```tsx
266
+ <Stack direction={{ base: 'column', md: 'row' }} gap="sm" align="center" justify="between" wrap>…</Stack>
267
+ ```
268
+
269
+ #### `Grid`
270
+
271
+ A CSS grid. Polymorphic, default `div`.
272
+
273
+ | Prop | Type | Default |
274
+ |---|---|---|
275
+ | `cols` | `Responsive<Cols>` | `1` |
276
+ | `gap` | `Responsive<Space>` | `'md'` |
277
+
278
+ - A single number is treated as `{ base: 1, md: n }`, so `cols={3}` is one column on phones and three from `md`.
279
+ - A breakpoint object without `base` gets `base: 1`.
280
+
281
+ ```tsx
282
+ <Grid cols={{ md: 2, xl: 4 }} gap="lg">…</Grid>
283
+ ```
284
+
285
+ #### `Container`
286
+
287
+ A centred, max-width page column with fluid side gutters (1rem up to 2rem). Polymorphic, default `div`.
288
+
289
+ | Prop | Type | Default |
290
+ |---|---|---|
291
+ | `size` | `'md' \| 'lg' \| 'xl'`: 48rem, 64rem, 80rem max width | `'xl'` |
292
+
293
+ #### `Section`
294
+
295
+ A full-width page band with fluid vertical padding. Polymorphic, default `section`.
296
+
297
+ | Prop | Type | Default |
298
+ |---|---|---|
299
+ | `tone` | `SurfaceTone` | none |
300
+ | `padding` | `'md' \| 'lg' \| 'xl'`: fluid, about 2–4rem, 3–6rem and 4–8rem | `'lg'` |
301
+ | `pattern` | `'none' \| 'dots' \| 'grid'` | `'none'` |
302
+
303
+ ```tsx
304
+ <Section tone="subtle" pattern="dots" padding="xl">
305
+ <Container>…</Container>
306
+ </Section>
307
+ ```
308
+
309
+ #### `Split`
310
+
311
+ Main content plus an aside, side by side from `xl` and stacked below it.
312
+
313
+ | Prop | Type | Default |
314
+ |---|---|---|
315
+ | `aside` **Req.** | `ReactNode` | none |
316
+ | `children` **Req.** | `ReactNode` (main content) | none |
317
+ | `ratio` | `'8/4' \| '1/1' \| '9/3'` (out of 12 columns) | `'8/4'` |
318
+ | `sticky` | `boolean`: the aside sticks while scrolling (xl+) | `false` |
319
+ | `gap` | `Responsive<Space>` | `'lg'` |
320
+
321
+ ```tsx
322
+ <Split aside={<ProgressCard />} sticky>
323
+ <ProblemList />
324
+ </Split>
325
+ ```
326
+
327
+ ### Typography
328
+
329
+ #### `Text`
330
+
331
+ Body text. Polymorphic, default `p`.
332
+
333
+ | Prop | Type | Default |
334
+ |---|---|---|
335
+ | `variant` | `'body-lead' \| 'body-md' \| 'body-sm' \| 'label' \| 'code'` | `'body-md'` |
336
+ | `tone` | `Tone` | `'default'` |
337
+ | `weight` | `'regular' \| 'medium' \| 'semibold'` | `'regular'` |
338
+ | `truncate` | `boolean`: a single line with an ellipsis | `false` |
339
+ | `clamp` | `1 \| 2 \| 3 \| 4`: the number of lines before an ellipsis | none |
340
+
341
+ `label` is JetBrains Mono in uppercase. Long words wrap instead of overflowing.
342
+
343
+ ```tsx
344
+ <Text variant="body-sm" tone="muted" clamp={2}>{summary}</Text>
345
+ ```
346
+
347
+ #### `Heading`
348
+
349
+ | Prop | Type | Default |
350
+ |---|---|---|
351
+ | `level` **Req.** | `1 \| 2 \| 3 \| 4`: which element (`h1`–`h4`) | none |
352
+ | `size` | `Responsive<HeadingSize>` | from the level: 1→`xl`, 2→`lg`, 3→`md`, 4→`sm` |
353
+ | `tone` | `'default' \| 'muted' \| 'brand' \| 'inverse'` | `'default'` |
354
+
355
+ `display`, `xl` and `lg` scale fluidly with the viewport. `level` sets the document outline and `size` sets the look, so they are independent.
356
+
357
+ ```tsx
358
+ <Heading level={1} size={{ base: 'lg', md: 'display' }}>Pattern library</Heading>
359
+ ```
360
+
361
+ #### `Eyebrow`
362
+
363
+ A small uppercase pill with a status dot, used above hero headings.
364
+
365
+ | Prop | Type | Default |
366
+ |---|---|---|
367
+ | `children` **Req.** | `ReactNode` | none |
368
+ | `tone` | `StatusTone` (the dot colour) | `'brand'` |
369
+
370
+ #### `Code`
371
+
372
+ Inline code. Props: `children`.
373
+
374
+ #### `CodeBlock`
375
+
376
+ A dark code block. It scrolls horizontally inside itself, so long lines never widen the page. It is keyboard-focusable so the scroll area can be reached.
377
+
378
+ | Prop | Type | Default |
379
+ |---|---|---|
380
+ | `children` **Req.** | `ReactNode` (the code) | none |
381
+ | `language` | `string`: shown as a caption, with no highlighting | none |
382
+
383
+ #### `Markdown`
384
+
385
+ Renders GitHub-flavoured Markdown with library styles: headings, lists, task lists as check icons, inline and block code, tables in a horizontal scroller, links and blockquotes.
386
+
387
+ | Prop | Type |
388
+ |---|---|
389
+ | `children` **Req.** | `string` (the markdown source) |
390
+
391
+ Raw HTML in the source is **not** rendered, and `javascript:` links are stripped. That makes it safe for user- or admin-authored content.
392
+
393
+ ```tsx
394
+ <Markdown>{problem.statement}</Markdown>
395
+ ```
396
+
397
+ ### Display
398
+
399
+ #### `Icon`
400
+
401
+ | Prop | Type | Default |
402
+ |---|---|---|
403
+ | `name` **Req.** | `string`: a Material Symbols name | none |
404
+ | `size` | `'sm' \| 'md' \| 'lg'` (16, 20, 24px) | `'md'` |
405
+ | `tone` | `Tone \| 'inherit'` | `'inherit'` |
406
+ | `filled` | `boolean` | `false` |
407
+ | `spin` | `boolean` | `false` |
408
+ | `label` | `string` | none |
409
+
410
+ Without `label` the icon is decorative (`aria-hidden`). With a `label`, screen readers announce it as an image.
411
+
412
+ #### `Dot`
413
+
414
+ A small coloured status dot, always decorative.
415
+
416
+ | Prop | Type | Default |
417
+ |---|---|---|
418
+ | `tone` | `StatusTone` | `'neutral'` |
419
+ | `size` | `'sm' \| 'md'` | `'sm'` |
420
+ | `pulse` | `boolean` | `false` |
421
+
422
+ #### `Badge`
423
+
424
+ | Prop | Type | Default |
425
+ |---|---|---|
426
+ | `children` **Req.** | `ReactNode` | none |
427
+ | `tone` | `BadgeTone` | `'neutral'` |
428
+ | `size` | `'sm' \| 'md'` | `'sm'` |
429
+ | `uppercase` | `boolean` | `false` |
430
+
431
+ ```tsx
432
+ <Badge tone="success" uppercase>Beginner</Badge>
433
+ ```
434
+
435
+ #### `Chip`
436
+
437
+ An outlined tag, such as a pattern category. It can be removable.
438
+
439
+ | Prop | Type | Default |
440
+ |---|---|---|
441
+ | `children` **Req.** | `string` | none |
442
+ | `tone` | `'neutral' \| 'brand'` | `'neutral'` |
443
+ | `icon` | `string` | none |
444
+ | `onRemove` | `() => void`: shows a remove button named "Remove {children}" | none |
445
+
446
+ #### `Stat`
447
+
448
+ An icon with a small label above a large value.
449
+
450
+ | Prop | Type |
451
+ |---|---|
452
+ | `icon` **Req.** | `string` |
453
+ | `label` **Req.** | `ReactNode` |
454
+ | `value` **Req.** | `ReactNode` |
455
+
456
+ #### `ProgressBar`
457
+
458
+ | Prop | Type | Default |
459
+ |---|---|---|
460
+ | `label` **Req.** | `string`: the visible label, which also names the bar | none |
461
+ | `value` **Req.** | `number` | none |
462
+ | `max` | `number` | `100` |
463
+ | `tone` | `'brand' \| 'success' \| 'warning' \| 'danger'` | `'brand'` |
464
+ | `hideLabel` | `boolean`: keeps the label for screen readers only | `false` |
465
+
466
+ `value` is clamped to `0…max`. A `max` of 0 or less shows 0%.
467
+
468
+ ```tsx
469
+ <ProgressBar label="Creational" value={3} max={5} tone="success" />
470
+ ```
471
+
472
+ #### `SectionHeader`
473
+
474
+ A header row for a group of items: dot, heading, tag and a right-aligned meta line.
475
+
476
+ | Prop | Type | Default |
477
+ |---|---|---|
478
+ | `title` **Req.** | `ReactNode` | none |
479
+ | `level` | `2 \| 3` | `2` |
480
+ | `dot` | `StatusTone` | none |
481
+ | `tag` | `ReactNode`: shown as an uppercase badge | none |
482
+ | `meta` | `ReactNode` | none |
483
+
484
+ #### `Callout`
485
+
486
+ A tinted notice box. `danger` is announced as an alert, and the other tones as a status.
487
+
488
+ | Prop | Type | Default |
489
+ |---|---|---|
490
+ | `children` **Req.** | `ReactNode` | none |
491
+ | `tone` | `'info' \| 'success' \| 'warning' \| 'danger'` | `'info'` |
492
+ | `title` | `ReactNode` | none |
493
+ | `action` | `ReactNode`, such as a `Button` | none |
494
+
495
+ #### `ResultRow`
496
+
497
+ One test result or submission row. The status icon carries an accessible name: "Passed", "Failed" or "Pending".
498
+
499
+ | Prop | Type |
500
+ |---|---|
501
+ | `status` **Req.** | `'pass' \| 'fail' \| 'pending'` |
502
+ | `title` **Req.** | `ReactNode` |
503
+ | `detail` | `ReactNode`: monospace, keeps line breaks |
504
+ | `meta` | `ReactNode`, such as a duration |
505
+
506
+ #### `Message`
507
+
508
+ A one-line loading, empty or error message. `danger` is announced as an alert, and the default as a status.
509
+
510
+ | Prop | Type | Default |
511
+ |---|---|---|
512
+ | `children` **Req.** | `ReactNode` | none |
513
+ | `tone` | `'default' \| 'danger'` | `'default'` |
514
+
515
+ #### `EmptyState`
516
+
517
+ | Prop | Type | Default |
518
+ |---|---|---|
519
+ | `title` **Req.** | `ReactNode` | none |
520
+ | `icon` | `string` | `'inbox'` |
521
+ | `description` | `ReactNode` | none |
522
+ | `action` | `ReactNode` | none |
523
+
524
+ #### `CheckList`
525
+
526
+ | Prop | Type |
527
+ |---|---|
528
+ | `items` **Req.** | `ReactNode[]`, each rendered with a check icon |
529
+
530
+ #### `Card`
531
+
532
+ A bordered, rounded surface. Polymorphic, default `div`.
533
+
534
+ | Prop | Type | Default |
535
+ |---|---|---|
536
+ | `padding` | `Responsive<Space>`: the body padding | `'lg'` |
537
+ | `tone` | `'default' \| 'inverse'` (dark obsidian card) | `'default'` |
538
+ | `interactive` | `boolean`: hover shadow and focus ring, for link cards | `false` |
539
+
540
+ Sub-components:
541
+
542
+ - **`Card.Media`** is always rendered first, edge to edge.
543
+
544
+ | Prop | Type | Default |
545
+ |---|---|---|
546
+ | `pattern` | `'none' \| 'dots' \| 'grid'` | `'dots'` |
547
+ | `aspect` | `'video' \| 'wide' \| 'square'` | `'video'` |
548
+ | `children` | `ReactNode` (centred overlay) | none |
549
+
550
+ - **`Card.Footer`** is always rendered last as a tinted footer bar. It takes only `children`.
551
+
552
+ All other children go into the padded body, whatever their order in the JSX.
553
+
554
+ ```tsx
555
+ <Card as={Link} href="/problem/singleton" interactive>
556
+ <Card.Media pattern="dots"><Icon name="deployed_code" size="lg" tone="muted" /></Card.Media>
557
+ <Badge tone="success" uppercase>Beginner</Badge>
558
+ <Heading level={3} size="sm">Singleton logger</Heading>
559
+ <Card.Footer><Text variant="label" tone="muted">4 languages</Text></Card.Footer>
560
+ </Card>
561
+ ```
562
+
563
+ ### Inputs and interaction
564
+
565
+ #### `Button`
566
+
567
+ Polymorphic, default `button`.
568
+
569
+ | Prop | Type | Default |
570
+ |---|---|---|
571
+ | `children` **Req.** | `ReactNode` (the label) | none |
572
+ | `variant` | `ButtonVariant` | `'primary'` |
573
+ | `size` | `'sm' \| 'md' \| 'lg'` (32, 40, 48px tall) | `'md'` |
574
+ | `icon` | `string`: an icon before the label | none |
575
+ | `iconRight` | `string`: an icon after the label | none |
576
+ | `fullWidth` | `boolean` | `false` |
577
+ | `loading` | `boolean`: disables the button, shows a spinner and sets `aria-busy` | `false` |
578
+ | `disabled` | `boolean` | `false` |
579
+
580
+ As a native button it defaults to `type="button"`; pass `type="submit"` for forms. When rendered through `as` (for example as a link), `disabled` sets `aria-disabled` and blocks pointer events. `ref` is forwarded.
581
+
582
+ ```tsx
583
+ <Button variant="secondary" size="sm" icon="play_arrow" onClick={run}>Run</Button>
584
+ <Button type="submit" loading={saving}>Save</Button>
585
+ ```
586
+
587
+ #### `IconButton`
588
+
589
+ A square, icon-only button. All `<button>` props are forwarded.
590
+
591
+ | Prop | Type | Default |
592
+ |---|---|---|
593
+ | `icon` **Req.** | `string` | none |
594
+ | `label` **Req.** | `string`: the accessible name and tooltip | none |
595
+ | `variant` | `'ghost' \| 'subtle' \| 'primary'` | `'ghost'` |
596
+ | `size` | `'sm' \| 'md'` (32, 40px) | `'md'` |
597
+
598
+ #### `Kbd`
599
+
600
+ A keyboard hint, e.g. `<Kbd>⌘K</Kbd>`. Props: `children`.
601
+
602
+ #### `TextField`
603
+
604
+ A labelled text input. All `<input>` props are forwarded, so it works controlled or uncontrolled.
605
+
606
+ | Prop | Type | Default |
607
+ |---|---|---|
608
+ | `label` **Req.** | `string` | none |
609
+ | `hideLabel` | `boolean`: keeps the label for screen readers only | `false` |
610
+ | `icon` | `string`: a leading icon | none |
611
+ | `hint` | `ReactNode`: trailing content, such as `<Kbd>⌘K</Kbd>` | none |
612
+ | `error` | `string`: sets `aria-invalid` and links the message as the description | none |
613
+
614
+ ```tsx
615
+ <TextField label="Search problems" hideLabel icon="search" hint={<Kbd>⌘K</Kbd>} value={q} onChange={(e) => setQ(e.target.value)} />
616
+ ```
617
+
618
+ #### `Select`
619
+
620
+ A styled native `<select>`. All `<select>` props (`value`, `defaultValue`, `onChange` and so on) are forwarded.
621
+
622
+ | Prop | Type | Default |
623
+ |---|---|---|
624
+ | `label` **Req.** | `string` | none |
625
+ | `options` **Req.** | `{ value: string; label: string }[]` | none |
626
+ | `hideLabel` | `boolean` | `false` |
627
+
628
+ #### `Tabs`
629
+
630
+ A tab strip that scrolls horizontally when it doesn't fit.
631
+
632
+ | Prop | Type | Default |
633
+ |---|---|---|
634
+ | `label` **Req.** | `string`: the accessible name of the group | none |
635
+ | `items` **Req.** | `TabItem[]` | none |
636
+ | `value` **Req.** | `string`: the active item `id` | none |
637
+ | `onChange` | `(id: string) => void` | none |
638
+ | `variant` | `'underline' \| 'pills'` | `'underline'` |
639
+
640
+ `TabItem`: `{ id: string; label: ReactNode; count?: number; dot?: StatusTone; href?: string; as?: ElementType }`
641
+
642
+ It has two modes:
643
+
644
+ - **Tablist** (no item has `href`): an ARIA tablist. Arrow keys, Home and End move between tabs and select them. Render the panel yourself based on `value`.
645
+ - **Navigation** (any item has `href`): a `<nav>` of links. The active link gets `aria-current="page"`. Use `as` for your router's link component.
646
+
647
+ ```tsx
648
+ <Tabs label="Filter" value={tab} onChange={setTab} items={[{ id: 'all', label: 'All', count: 40 }, { id: 'solved', label: 'Solved', dot: 'success' }]} />
649
+ <Tabs label="Site" value="problems" items={[{ id: 'problems', label: 'Problems', href: '/problems', as: Link }]} />
650
+ ```
651
+
652
+ #### `SegmentedControl`
653
+
654
+ A single-choice pill group, such as a language picker. It is an ARIA radio group: arrow keys move and select.
655
+
656
+ | Prop | Type |
657
+ |---|---|
658
+ | `label` **Req.** | `string` |
659
+ | `options` **Req.** | `{ value: string; label: string; icon?: string }[]` |
660
+ | `value` **Req.** | `string` |
661
+ | `onChange` **Req.** | `(value: string) => void` |
662
+
663
+ #### `Dialog`
664
+
665
+ A modal dialog rendered in a portal.
666
+
667
+ | Prop | Type | Default |
668
+ |---|---|---|
669
+ | `open` **Req.** | `boolean` | none |
670
+ | `onClose` **Req.** | `() => void`: called on Escape, a backdrop click or the close button | none |
671
+ | `title` **Req.** | `ReactNode` (names the dialog) | none |
672
+ | `description` | `ReactNode` (describes the dialog) | none |
673
+ | `footer` | `ReactNode`: actions, right-aligned | none |
674
+ | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` |
675
+ | `children` | `ReactNode` (the body) | none |
676
+
677
+ - **Focus:** focus moves to the first focusable element in the body, Tab and Shift+Tab stay inside the dialog, and on close focus returns to the element that opened it.
678
+ - **Page:** the page behind can't scroll while the dialog is open.
679
+ - **Theme:** the dialog inherits the opener's `<Theme>`.
680
+ - On small screens it docks to the bottom of the viewport.
681
+
682
+ ```tsx
683
+ <Dialog open={open} onClose={() => setOpen(false)} title="Sign in" description="Save your progress." footer={<Button type="submit" form="login">Sign in</Button>}>
684
+ <form id="login">…</form>
685
+ </Dialog>
686
+ ```
687
+
688
+ #### `Menu`
689
+
690
+ A menu button, such as an account menu.
691
+
692
+ | Prop | Type | Default |
693
+ |---|---|---|
694
+ | `label` **Req.** | `string`: the menu's accessible name | none |
695
+ | `trigger` **Req.** | `(props: MenuTriggerProps) => ReactNode`: spread `props` onto a `Button` | none |
696
+ | `items` **Req.** | `MenuItem[]` | none |
697
+ | `align` | `'start' \| 'end'`: which edge of the trigger the menu aligns to | `'end'` |
698
+
699
+ `MenuItem`: `{ label: string; icon?: string; onSelect?: () => void; href?: string; as?: ElementType; tone?: 'default' | 'danger' }`
700
+
701
+ Keyboard and pointer behaviour:
702
+ - Click toggles the menu.
703
+ - On the trigger, ArrowDown, Enter or Space opens the menu at the first item, and ArrowUp opens it at the last.
704
+ - Inside the menu, arrows, Home and End move between items.
705
+ - Escape closes and refocuses the trigger. Tab or a click outside closes.
706
+
707
+ ```tsx
708
+ <Menu
709
+ label="Account"
710
+ items={[{ label: 'Profile', icon: 'person', href: '/me', as: Link }, { label: 'Sign out', icon: 'logout', tone: 'danger', onSelect: signOut }]}
711
+ trigger={(p) => <Button {...p} variant="ghost" icon="account_circle">Account</Button>}
712
+ />
713
+ ```
714
+
715
+ ### IDE shell
716
+
717
+ #### `Workbench`
718
+
719
+ An IDE layout: an optional header, a left panel, the main area, a right panel and a bottom panel, with resizable separators.
720
+
721
+ | Prop | Type | Default |
722
+ |---|---|---|
723
+ | `main` **Req.** | `ReactNode` | none |
724
+ | `header` | `ReactNode` | none |
725
+ | `left` | `ReactNode` | none |
726
+ | `right` | `ReactNode` | none |
727
+ | `bottom` | `ReactNode` | none |
728
+ | `labels` | `Partial<{ left; main; right; bottom }>` (region names) | `Explorer`, `Editor`, `Details`, `Panel` |
729
+ | `defaultSizes` | `Partial<{ left: px; right: px; bottom: % }>` | `{ left: 240, right: 380, bottom: 30 }` |
730
+ | `limits` | `Partial<{ left: [min, max]; right: [min, max]; bottom: [min, max] }>` | `left [160, 480]`, `right [260, 640]`, `bottom [15, 70]` |
731
+ | `persistKey` | `string`: remembers sizes in `localStorage` under this key | none |
732
+
733
+ - **Resizing:** drag a separator, or focus it and use the arrow keys (16px steps, or 5% for the bottom panel). Home and End jump to the minimum and maximum.
734
+ - **Saved sizes:** they are read after mount, so server rendering is safe. Corrupt or out-of-range values are ignored, and blocked storage is tolerated.
735
+ - **Below `lg`:** the left and right panels become slide-over drawers. Open them with `<Workbench.Toggle panel="left" />` or `<Workbench.Toggle panel="right" />`, placed anywhere inside `header`. Escape or a backdrop click closes them.
736
+ - **Below `md`:** a switch toggles between the main area and the bottom panel.
737
+ - **Height:** give the Workbench a parent with a fixed height, e.g. `h-dvh` or a flex child.
738
+
739
+ ```tsx
740
+ <Workbench
741
+ persistKey="ide"
742
+ header={<><Workbench.Toggle panel="left" /><Breadcrumbs items={crumbs} /><Workbench.Toggle panel="right" /></>}
743
+ left={<FileTree label="Files" nodes={files} activePath={active} onOpen={setActive} />}
744
+ main={<Editor />}
745
+ right={<Statement />}
746
+ bottom={<TestResults />}
747
+ />
748
+ ```
749
+
750
+ #### `FileTree`
751
+
752
+ A keyboard-navigable file tree, built from flat paths.
753
+
754
+ | Prop | Type | Default |
755
+ |---|---|---|
756
+ | `label` **Req.** | `string` | none |
757
+ | `nodes` **Req.** | `FileNode[]` | none |
758
+ | `onOpen` **Req.** | `(path: string) => void`: called when a file is opened | none |
759
+ | `activePath` | `string`: the selected file | none |
760
+ | `defaultExpanded` | `string[] \| 'all'` (directory paths) | `'all'` |
761
+
762
+ `FileNode`: `{ path: string; kind: 'file' | 'dir'; readOnly?: boolean; modified?: boolean }`
763
+
764
+ - **Building the tree:** paths are `/`-separated, missing parent directories are created, and duplicate paths keep the first entry. Directories sort first, then names alphabetically.
765
+ - **Keyboard:** Up and Down move between items. Right expands a directory or enters it, and Left collapses it or goes to the parent. Home and End jump to the ends. Enter opens a file or toggles a directory.
766
+ - **Markers:** read-only files show a lock, and modified files show a dot. Both are announced to screen readers.
767
+
768
+ #### `EditorTabs`
769
+
770
+ Tabs for open files. They scroll horizontally, and a middle-click closes a tab.
771
+
772
+ | Prop | Type | Default |
773
+ |---|---|---|
774
+ | `tabs` **Req.** | `{ id: string; label: string; modified?: boolean; readOnly?: boolean }[]` | none |
775
+ | `activeId` **Req.** | `string` | none |
776
+ | `onSelect` **Req.** | `(id: string) => void` | none |
777
+ | `onClose` | `(id: string) => void`: shows close buttons | none |
778
+ | `label` | `string` | `'Open files'` |
779
+
780
+ #### `Breadcrumbs`
781
+
782
+ | Prop | Type | Default |
783
+ |---|---|---|
784
+ | `items` **Req.** | `{ label: string; href?: string; as?: ElementType }[]` | none |
785
+ | `label` | `string` | `'Breadcrumb'` |
786
+
787
+ The last item is the current page. With three or more items, the middle ones collapse to `…` below `md`.
788
+
789
+ #### `StatusBar`
790
+
791
+ A thin bar at the bottom of the IDE.
792
+
793
+ | Prop | Type | Default |
794
+ |---|---|---|
795
+ | `start` | `ReactNode` (left side) | none |
796
+ | `end` | `ReactNode` (right side) | none |
797
+ | `label` | `string` | `'Status'` |
798
+
799
+ `StatusBar.Item` takes `children` (required), `icon?: string`, and `tone?: 'default' | 'success' | 'danger' | 'warning' | 'brand'`.
800
+
801
+ ```tsx
802
+ <StatusBar start={<StatusBar.Item icon="check_circle" tone="success">Ready</StatusBar.Item>} end={<StatusBar.Item>TypeScript</StatusBar.Item>} />
803
+ ```
804
+
805
+ #### `MetricTile`
806
+
807
+ | Prop | Type | Default |
808
+ |---|---|---|
809
+ | `label` **Req.** | `ReactNode` | none |
810
+ | `value` **Req.** | `ReactNode` | none |
811
+ | `tone` | `'neutral' \| 'success' \| 'danger'` | `'neutral'` |
812
+ | `icon` | `string` | none |
813
+
814
+ #### `Avatar`
815
+
816
+ | Prop | Type | Default |
817
+ |---|---|---|
818
+ | `name` **Req.** | `string`: used for the initials and the accessible name | none |
819
+ | `src` | `string`: the image. If it's missing or fails to load, initials show instead | none |
820
+ | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` |
821
+ | `badge` | `ReactNode`, such as a score, shown at the corner | none |
822
+
823
+ #### `Countdown`
824
+
825
+ A timer that counts down, or up.
826
+
827
+ | Prop | Type | Default |
828
+ |---|---|---|
829
+ | `seconds` | `number`: the duration (down), or the starting offset (up) | `0` |
830
+ | `until` | `Date`: the deadline (down only; overrides `seconds`) | none |
831
+ | `direction` | `'down' \| 'up'` | `'down'` |
832
+ | `warnAt` | `number`: switches to the danger colour at or below this many seconds | none |
833
+ | `onExpire` | `() => void`: fired once when a countdown reaches 0 | none |
834
+ | `label` | `string` (accessible name) | `'Time remaining'` |
835
+
836
+ It shows `mm:ss`, or `h:mm:ss` from one hour. A deadline already in the past shows `00:00` and fires `onExpire` right away. Unmounting stops the timer, and `onExpire` won't fire afterwards.
837
+
838
+ ---
839
+
840
+ ## Design tokens
841
+
842
+ `theme.css` registers every token as a Tailwind v4 theme variable, so it is available both as a utility (`bg-surface`) and as a CSS variable (`var(--color-surface)`). Use the variables in the app's own CSS when you need them outside components.
843
+
844
+ | Group | Tokens |
845
+ |---|---|
846
+ | Surfaces | `--color-surface`, `-surface-subtle`, `-surface-elevated`, `-surface-muted`, `-surface-container-low` |
847
+ | Text | `--color-on-surface`, `-on-surface-variant` (muted), `-ink` (strong), `-on-ink` |
848
+ | Status text (meets AA contrast in both themes) | `--color-fg-brand`, `-fg-success`, `-fg-warning`, `-fg-danger` |
849
+ | Brand fills | `--color-brand-cobalt`, `-brand-emerald`, `-brand-amber`, `-brand-crimson`, `-brand-obsidian`, `-brand-slate` |
850
+ | Borders | `--color-border-subtle`, `-border-strong` |
851
+ | Badges | `--color-badge-{beginner,intermediate,amber,advanced}-{bg,text}` |
852
+ | Spacing | `--spacing-space-{2xs,xs,sm,md,lg,xl,2xl}`, `--spacing-gutter-fluid`, `--spacing-section-{md,lg,xl}` |
853
+ | Type | `--text-{display,headline-xl,headline-lg,headline-md,headline-sm,body-lead,body-md,body-sm,label-mono,code-inline,button-text}` |
854
+
855
+ Every token under Surfaces, Text, Status text, Borders and Badges changes inside `[data-theme="dark"]`, which is what `<Theme tone="dark">` renders.
856
+
857
+ ## Accessibility
858
+
859
+ - **Interactive widgets:** they follow the WAI-ARIA Authoring Practices.
860
+ - `Tabs` is a tablist, `SegmentedControl` a radio group, and `Menu` a menu button.
861
+ - `FileTree` is a tree view, and the `Workbench` resize handles are separators with values.
862
+ - `Dialog` is a modal dialog.
863
+ - **Accessible names:** icon-only controls require a `label` (`IconButton`), and status icons have names (`ResultRow`).
864
+ - **Focus and touch:** focus rings are visible on keyboard focus, and touch targets are at least 44px below `md`.
865
+ - **Contrast:** status text colours meet WCAG AA in both themes.
866
+ - **CI checks:** every gallery story runs through axe, and critical or serious violations fail the build.
867
+
868
+ ## Troubleshooting
869
+
870
+ | Symptom | Fix |
871
+ |---|---|
872
+ | Components render unstyled, or some classes are missing | The `@source` path is wrong: resolve it relative to the CSS file. Also check that the app uses Tailwind **v4**. |
873
+ | Icons show as words (`play_arrow`) | Load the Material Symbols Outlined stylesheet. |
874
+ | Wrong fonts | Set `--font-space-grotesk`, `--font-inter` and `--font-jetbrains-mono`, for example on `<html>` through `next/font`'s `variable` option. |
875
+ | TypeScript error on `className` | This is intentional: use a variant prop, or add a variant to the library. |
876
+ | `Workbench` has no height | Give its parent an explicit height, e.g. `h-dvh`, or make it a flex child with `min-h-0 flex-1`. |
877
+
878
+ ## Development
879
+
880
+ ```bash
881
+ npm install
882
+ npm test # unit tests (vitest + jsdom)
883
+ npm run typecheck # includes the type test that forbids className/style
884
+ npm run lint
885
+ npm run build # tsup → dist/ (ESM + .d.ts + theme.css)
886
+ npm run ladle # component gallery on http://localhost:61000
887
+ npm run ladle:build && npm run e2e # every story at 390/768/1024/1440px (light) + 1024px dark, overflow + axe
888
+ npm run package-check # pack the tarball and build a real Next.js 16 + Tailwind v4 consumer
889
+ ```
890
+
891
+ Source layout: `src/primitives` (layout and typography), `src/components`, `src/ide`, `src/tokens/theme.css`, `src/internal` (class tables and helpers), and `src/stories` (the Ladle gallery).
892
+
893
+ When adding a component:
894
+ 1. Write every Tailwind class as a complete literal string, never built with template strings, or the app's Tailwind scan won't see it.
895
+ 2. Keep `className` and `style` out of its props.
896
+ 3. Add a unit test and a story.
897
+
898
+ ## Releasing
899
+
900
+ ```bash
901
+ npm version patch # or minor; 0.x minors may break
902
+ git push --follow-tags # the v* tag runs .github/workflows/release.yml
903
+ ```
904
+
905
+ The release workflow checks that the tag matches `package.json`, runs the tests, builds, and publishes through **npm Trusted Publishing** (GitHub OIDC) with provenance. No npm token is stored.
906
+
907
+ ## License
908
+
909
+ MIT