@overdoser/react-toolkit 0.18.0 → 0.19.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.
Files changed (156) hide show
  1. package/AGENTS.md +51 -7
  2. package/CHANGELOG.md +129 -0
  3. package/components/Accordion/Accordion.d.ts +94 -0
  4. package/components/Accordion/Accordion.js +180 -0
  5. package/components/Accordion/Accordion.module.scss.js +36 -0
  6. package/components/Accordion/index.d.ts +2 -0
  7. package/components/Alert/Alert.d.ts +29 -1
  8. package/components/Alert/Alert.js +44 -30
  9. package/components/Alert/Alert.module.scss.js +24 -16
  10. package/components/Alert/index.d.ts +1 -1
  11. package/components/Card/Card.d.ts +86 -0
  12. package/components/Card/Card.js +132 -0
  13. package/components/Card/Card.module.scss.js +60 -0
  14. package/components/Card/index.d.ts +2 -0
  15. package/components/Chip/Chip.d.ts +86 -0
  16. package/components/Chip/Chip.js +141 -0
  17. package/components/Chip/Chip.module.scss.js +59 -0
  18. package/components/Chip/index.d.ts +2 -0
  19. package/components/CodeBlock/CodeBlock.d.ts +78 -0
  20. package/components/CodeBlock/CodeBlock.js +120 -0
  21. package/components/CodeBlock/CodeBlock.module.scss.js +43 -0
  22. package/components/CodeBlock/index.d.ts +2 -0
  23. package/components/CommandPalette/CommandPalette.d.ts +141 -0
  24. package/components/CommandPalette/CommandPalette.js +397 -0
  25. package/components/CommandPalette/CommandPalette.module.scss.js +49 -0
  26. package/components/CommandPalette/index.d.ts +2 -0
  27. package/components/ConfirmDialog/ConfirmDialog.d.ts +119 -0
  28. package/components/ConfirmDialog/ConfirmDialog.js +201 -0
  29. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +21 -0
  30. package/components/ConfirmDialog/index.d.ts +2 -0
  31. package/components/Drawer/Drawer.d.ts +1 -0
  32. package/components/Drawer/Drawer.js +35 -36
  33. package/components/Drawer/Drawer.module.scss.js +20 -18
  34. package/components/Dropdown/Dropdown.d.ts +47 -7
  35. package/components/Dropdown/Dropdown.js +174 -81
  36. package/components/Dropdown/Dropdown.module.scss.js +40 -22
  37. package/components/Dropdown/DropdownItem.d.ts +31 -2
  38. package/components/Dropdown/DropdownItem.js +54 -27
  39. package/components/Dropdown/DropdownLabel.d.ts +11 -0
  40. package/components/Dropdown/DropdownLabel.js +11 -0
  41. package/components/Dropdown/DropdownSeparator.d.ts +12 -0
  42. package/components/Dropdown/DropdownSeparator.js +11 -0
  43. package/components/Dropdown/dropdownContext.d.ts +6 -0
  44. package/components/Dropdown/dropdownContext.js +5 -0
  45. package/components/Dropdown/index.d.ts +8 -2
  46. package/components/Dropdown/useContextMenu.d.ts +32 -0
  47. package/components/Dropdown/useContextMenu.js +18 -0
  48. package/components/EmptyState/EmptyState.d.ts +53 -0
  49. package/components/EmptyState/EmptyState.js +55 -0
  50. package/components/EmptyState/EmptyState.module.scss.js +25 -0
  51. package/components/EmptyState/index.d.ts +2 -0
  52. package/components/Form/FormField.js +25 -24
  53. package/components/ImageViewer/ImageViewer.d.ts +105 -0
  54. package/components/ImageViewer/ImageViewer.js +201 -0
  55. package/components/ImageViewer/ImageViewer.module.scss.js +47 -0
  56. package/components/ImageViewer/index.d.ts +4 -0
  57. package/components/ImageViewer/useZoomPan.d.ts +94 -0
  58. package/components/ImageViewer/useZoomPan.js +141 -0
  59. package/components/Kbd/Kbd.d.ts +26 -0
  60. package/components/Kbd/Kbd.js +22 -0
  61. package/components/Kbd/Kbd.module.scss.js +17 -0
  62. package/components/Kbd/index.d.ts +2 -0
  63. package/components/KeyValueList/KeyValueList.d.ts +84 -0
  64. package/components/KeyValueList/KeyValueList.js +127 -0
  65. package/components/KeyValueList/KeyValueList.module.scss.js +43 -0
  66. package/components/KeyValueList/index.d.ts +2 -0
  67. package/components/Modal/Modal.d.ts +1 -0
  68. package/components/Modal/Modal.js +40 -41
  69. package/components/Modal/Modal.module.scss.js +18 -16
  70. package/components/PageHeader/PageHeader.d.ts +61 -0
  71. package/components/PageHeader/PageHeader.js +73 -0
  72. package/components/PageHeader/PageHeader.module.scss.js +43 -0
  73. package/components/PageHeader/index.d.ts +2 -0
  74. package/components/ProgressBar/ProgressBar.d.ts +74 -0
  75. package/components/ProgressBar/ProgressBar.js +90 -0
  76. package/components/ProgressBar/ProgressBar.module.scss.js +51 -0
  77. package/components/ProgressBar/index.d.ts +2 -0
  78. package/components/RelativeTime/RelativeTime.d.ts +45 -0
  79. package/components/RelativeTime/RelativeTime.js +43 -0
  80. package/components/RelativeTime/RelativeTime.module.scss.js +7 -0
  81. package/components/RelativeTime/index.d.ts +2 -0
  82. package/components/SegmentedControl/SegmentedControl.d.ts +84 -0
  83. package/components/SegmentedControl/SegmentedControl.js +131 -0
  84. package/components/SegmentedControl/SegmentedControl.module.scss.js +39 -0
  85. package/components/SegmentedControl/index.d.ts +2 -0
  86. package/components/SplitPane/SplitPane.d.ts +61 -0
  87. package/components/SplitPane/SplitPane.js +171 -0
  88. package/components/SplitPane/SplitPane.module.scss.js +25 -0
  89. package/components/SplitPane/index.d.ts +2 -0
  90. package/components/StatCard/StatCard.d.ts +105 -0
  91. package/components/StatCard/StatCard.js +127 -0
  92. package/components/StatCard/StatCard.module.scss.js +72 -0
  93. package/components/StatCard/index.d.ts +2 -0
  94. package/components/StatusDot/StatusDot.d.ts +33 -0
  95. package/components/StatusDot/StatusDot.js +39 -0
  96. package/components/StatusDot/StatusDot.module.scss.js +32 -0
  97. package/components/StatusDot/index.d.ts +2 -0
  98. package/components/Table/Table.d.ts +100 -2
  99. package/components/Table/Table.js +371 -210
  100. package/components/Table/Table.module.scss.js +68 -46
  101. package/components/Table/index.d.ts +1 -1
  102. package/components/ThemeToggle/ThemeToggle.d.ts +38 -0
  103. package/components/ThemeToggle/ThemeToggle.js +97 -0
  104. package/components/ThemeToggle/ThemeToggle.module.scss.js +23 -0
  105. package/components/ThemeToggle/index.d.ts +2 -0
  106. package/components/inputs/Checkbox/Checkbox.d.ts +2 -0
  107. package/components/inputs/Checkbox/Checkbox.js +29 -28
  108. package/components/inputs/Checkbox/Checkbox.module.scss.js +8 -6
  109. package/components/inputs/Input/Input.d.ts +33 -1
  110. package/components/inputs/Input/Input.js +94 -35
  111. package/components/inputs/Input/Input.module.scss.js +14 -12
  112. package/components/inputs/Radio/Radio.d.ts +5 -4
  113. package/components/inputs/Radio/Radio.js +55 -50
  114. package/components/inputs/Radio/Radio.module.scss.js +12 -10
  115. package/components/inputs/SearchInput/SearchInput.d.ts +57 -0
  116. package/components/inputs/SearchInput/SearchInput.js +116 -0
  117. package/components/inputs/SearchInput/SearchInput.module.scss.js +13 -0
  118. package/components/inputs/SearchInput/index.d.ts +2 -0
  119. package/components/inputs/Select/Select.d.ts +52 -0
  120. package/components/inputs/Select/Select.js +494 -385
  121. package/components/inputs/Select/Select.module.scss.js +34 -30
  122. package/components/inputs/Switch/Switch.d.ts +15 -0
  123. package/components/inputs/Switch/Switch.js +8 -0
  124. package/components/inputs/Switch/index.d.ts +2 -0
  125. package/hooks/useDebouncedValue.d.ts +15 -0
  126. package/hooks/useDebouncedValue.js +15 -0
  127. package/hooks/useElementSize.d.ts +20 -0
  128. package/hooks/useElementSize.js +23 -0
  129. package/hooks/useKeyboard.d.ts +49 -5
  130. package/hooks/useKeyboard.js +66 -16
  131. package/hooks/useMediaQuery.d.ts +14 -0
  132. package/hooks/useMediaQuery.js +16 -0
  133. package/hooks/useNow.d.ts +14 -0
  134. package/hooks/useNow.js +35 -0
  135. package/hooks/usePersistedState.d.ts +30 -0
  136. package/hooks/usePersistedState.js +96 -0
  137. package/hooks/useResizable.d.ts +66 -0
  138. package/hooks/useResizable.js +105 -0
  139. package/hooks/useTheme.d.ts +33 -0
  140. package/hooks/useTheme.js +27 -0
  141. package/index.css +1 -1
  142. package/index.d.ts +58 -4
  143. package/index.js +208 -132
  144. package/index.layered.css +1 -1
  145. package/llms.txt +619 -25
  146. package/manifest.json +1739 -91
  147. package/package.json +1 -1
  148. package/recipes/confirm-modal.tsx +65 -53
  149. package/recipes/floating-copy-button.tsx +32 -28
  150. package/utils/formatBytes.d.ts +21 -0
  151. package/utils/formatBytes.js +14 -0
  152. package/utils/index.d.ts +6 -0
  153. package/utils/themeScript.d.ts +17 -0
  154. package/utils/themeScript.js +9 -0
  155. package/utils/timeAgo.d.ts +33 -0
  156. package/utils/timeAgo.js +37 -0
package/llms.txt CHANGED
@@ -24,6 +24,21 @@ Override CSS custom properties on `:root` to theme:
24
24
 
25
25
  All components forward `className` and `style`. Most also accept a `classes` object to override internal element classNames (see `*Classes` types per component).
26
26
 
27
+ ### Dark mode
28
+
29
+ The stylesheet ships a full dark token set. Contract: no attribute = follow the OS (`prefers-color-scheme`); `data-theme="light"` / `data-theme="dark"` on `<html>` forces a theme — and on **any element** forces it for that subtree (`<div data-theme="dark">` for a dark sidebar). `color-scheme` follows, so native controls and scrollbars match.
30
+
31
+ ```tsx
32
+ // <head>, before first paint — applies the stored choice without a flash
33
+ import { THEME_INIT_SCRIPT } from '@overdoser/react-toolkit';
34
+ <script dangerouslySetInnerHTML={{ __html: THEME_INIT_SCRIPT }} />
35
+
36
+ // anywhere: a toggle (icon cycles light → dark → system) or the hook
37
+ <ThemeToggle />
38
+ const { theme, resolved, setTheme, toggle } = useTheme(); // theme: 'light' | 'dark' | 'system'; resolved: 'light' | 'dark'
39
+ ```
40
+ The choice is stored in `localStorage` under `crk-theme` (`storageKey` option on both). Text-on-tint colours use the `--crk-color-*-text` tokens (`primary`, `info`, `success`, `warning`, `danger`); backdrops use `--crk-color-backdrop` / `--crk-color-backdrop-soft`; hover overlays `--crk-color-overlay-hover`. Override dark values under `[data-theme="dark"]` (and the `prefers-color-scheme` branch if you rely on it).
41
+
27
42
  ### Making your overrides always win (CSS ordering)
28
43
 
29
44
  `className` / `classes.*` overrides are plain CSS classes, so they only beat the toolkit's built-in class if your stylesheet is inserted **after** the toolkit's — which depends on your bundler and isn't guaranteed. Two ways to make overrides deterministic:
@@ -151,7 +166,7 @@ Example:
151
166
  <CopyButton value={shareUrl} iconOnly aria-label="Copy link" /> // icon only
152
167
  ```
153
168
 
154
- Floating over content (e.g. pinned to a code snippet's corner): `secondary`/`ghost` are transparent at rest, so wrap the button in a div with a solid `background: var(--crk-color-bg)` and the button's border radius — every state then composites over that surface instead of the content underneath. Prefer `variant="secondary"` there (visible outline at rest; ghost has none). Full copy-paste version: `recipes/floating-copy-button.tsx`.
169
+ Floating over content: for code use `<CodeBlock>` (it has the floating copy button built in). For any other box, `secondary`/`ghost` are transparent at rest, so wrap the button in a div with a solid `background: var(--crk-color-bg)` and the button's border radius — every state then composites over that surface instead of the content underneath. Prefer `variant="secondary"` there (visible outline at rest; ghost has none). Full copy-paste version: `recipes/floating-copy-button.tsx`.
155
170
 
156
171
  ### Link
157
172
  Import: `import { Link } from '@overdoser/react-toolkit'`
@@ -219,9 +234,15 @@ Props:
219
234
  - `rowKey?: keyof T & string` — column key to use as React key; falls back to row index.
220
235
  - `rowClassName?: string | ((row: T, index: number) => string | undefined)` — per-row class. Pass a string for a static class or a callback to compute it dynamically (e.g. highlight rows matching a predicate).
221
236
  - `rowStyle?: CSSProperties | ((row: T, index: number) => CSSProperties | undefined)` — per-row inline style. Same shape as `rowClassName`.
222
- - `emptyMessage?: ReactNode` — default `'No data'`
237
+ - `emptyMessage?: ReactNode` — default `'No data'`. Pass an `<EmptyState>` for a richer placeholder.
238
+ - `loading?: boolean` — default `false`. Overlays a `Loader` (150 ms delay) — rows stay mounted and keep their height; `aria-busy` on the table. With empty `data`, `loadingRows` (default `3`) skeleton rows render instead of `emptyMessage`.
239
+ - `onRowClick?: (row: T, index: number, event) => void` — rows become focusable (`tabIndex=0`), get a pointer/hover style and activate on Enter/Space. Clicks on interactive elements inside the row (button, a, input, select, label, `[role=button|checkbox|menuitem]`) are ignored, so per-row action buttons keep working.
240
+ - `selectable?: boolean` — default `false`. Leading checkbox column; needs `rowKey`. `selectedKeys?: TableRowKey[]` (controlled) / `defaultSelectedKeys?` / `onSelectionChange?: (keys: TableRowKey[], rows: T[]) => void`. `isRowSelectable?: (row: T) => boolean` disables some rows. Select-all covers the *current page* only (checked / `indeterminate`), other pages keep their selections; Shift-click selects a range. Selected rows get `aria-selected` + class `rowSelected`.
241
+ - `bulkActions?: ReactNode | ((ctx: { selectedKeys; selectedRows: T[]; clear() }) => ReactNode)` — bar above the table while something is selected: "N selected" (`selectionLabel?: (n) => ReactNode`), a Clear button, then your actions.
242
+ - `columnVisibility?: Record<string, boolean>` — `{ email: false }` hides a column (header + cells) without touching `columns`/sort config. Build the picker yourself (`CheckboxGroup` chips or `DropdownItem checked`).
243
+ - `layout?: 'auto' | 'fixed'` — default `'auto'`. `'fixed'` = `table-layout: fixed` so live-updating cells don't reflow column widths.
223
244
  - `pagination?: PaginationConfig` — see below. When omitted, all rows render.
224
- - `classes?: Partial<TableClasses>` where `TableClasses = { wrapper, root, headerCell, row, cell, emptyCell, paginator, pageButton }`
245
+ - `classes?: Partial<TableClasses>` where `TableClasses = { wrapper, root, headerCell, row, cell, emptyCell, paginator, pageButton, rowClickable, rowSelected, selectCell, selectHeaderCell, bulkBar, bulkLabel, bulkClear, bulkActions, loadingRow }`
225
246
 
226
247
  `ColumnDef<T>`:
227
248
  - `key: keyof T & string` — required.
@@ -315,6 +336,21 @@ const columns: ColumnDef<Row>[] = [
315
336
  ```
316
337
  Full copy-paste version: `recipes/comparison-table.tsx`.
317
338
 
339
+ Selection + bulk actions + loading + row click:
340
+ ```tsx
341
+ <Table
342
+ data={users} columns={columns} rowKey="id"
343
+ loading={isFetching}
344
+ onRowClick={(user) => navigate(`/users/${user.id}`)}
345
+ selectable selectedKeys={selected} onSelectionChange={(keys) => setSelected(keys)}
346
+ isRowSelectable={(u) => u.role !== 'Admin'}
347
+ bulkActions={({ selectedRows, clear }) => (
348
+ <Button size="sm" variant="danger" onClick={() => { archive(selectedRows); clear(); }}>Archive</Button>
349
+ )}
350
+ columnVisibility={{ email: showEmail }} layout="fixed"
351
+ />
352
+ ```
353
+
318
354
  ### `useTableSort` (hook)
319
355
  Import: `import { useTableSort } from '@overdoser/react-toolkit'`
320
356
  Signature: `useTableSort<T>(data: T[], initialSort?: SortConfig[])`
@@ -327,22 +363,26 @@ Returns:
327
363
 
328
364
  Use this only if you want to manage sort state outside `<Table>`; `<Table>` already does this internally when `onSort` is not supplied.
329
365
 
330
- ### Dropdown / DropdownItem
331
- Import: `import { Dropdown, DropdownItem } from '@overdoser/react-toolkit'`
366
+ ### Dropdown / DropdownItem / DropdownSeparator / DropdownLabel
367
+ Import: `import { Dropdown, DropdownItem, DropdownSeparator, DropdownLabel, useContextMenu } from '@overdoser/react-toolkit'`
332
368
 
333
- Two distinct usage modes — pick one:
369
+ Three usage modes — pick one:
334
370
 
335
- **Mode A — menu of arbitrary items:** pass `trigger` + `<DropdownItem>` children. The trigger button toggles a menu; clicking outside or pressing Escape closes it.
371
+ **Mode A — menu of arbitrary items:** pass `trigger` + `<DropdownItem>` children. The trigger button toggles a menu; clicking outside, pressing Escape, or activating an action item closes it.
336
372
 
337
373
  **Mode B — selectable form input:** pass `options` + `value` + `onChange`. The `trigger` prop is ignored; the selected option's label appears in the trigger.
338
374
 
375
+ **Mode C — context menu:** pass `anchor={{ x, y }}` (+ `open` / `onOpenChange`) and no trigger: the menu opens at that viewport point, clamped to the viewport. `useContextMenu()` wires it up from a right-click.
376
+
339
377
  `DropdownProps`:
340
- - `trigger?: ReactNode` — required for Mode A; ignored in Mode B.
341
- - `children?: ReactNode` — `<DropdownItem>` elements (Mode A).
378
+ - `trigger?: ReactNode` — required for Mode A; ignored in Mode B/C.
379
+ - `children?: ReactNode` — `<DropdownItem>` / `<DropdownSeparator>` / `<DropdownLabel>` elements (Mode A/C).
342
380
  - `options?: { value: string; label: ReactNode; disabled?: boolean }[]` — switches to Mode B.
343
381
  - `value?: string` — Mode B selected value.
344
382
  - `onChange?: (value: string) => void` — Mode B select callback.
345
383
  - `placeholder?: ReactNode` — default `'Select...'` (Mode B).
384
+ - `open?: boolean` + `onOpenChange?: (open: boolean) => void` — controlled open state (any mode). Uncontrolled when omitted; `onOpen` / `onClose` still fire.
385
+ - `anchor?: { x: number; y: number } | null` — Mode C. Passing the prop (even `null` = closed) selects the mode; the menu is portaled at the point, clamped to an 8px viewport margin and flipped on overflow. Type `DropdownAnchor`.
346
386
  - `align?: 'left' | 'right'` — default `'left'`. Menu alignment relative to trigger.
347
387
  - `error?: boolean` — default `false`
348
388
  - `fullWidth?: boolean` — default `true`
@@ -350,15 +390,36 @@ Two distinct usage modes — pick one:
350
390
  - `id?: string`
351
391
  - `onOpen?: () => void`
352
392
  - `onClose?: () => void`
353
- - `classes?: Partial<DropdownClasses>` where `DropdownClasses = { root, trigger, triggerLabel, chevron, menu, item }`
393
+ - `classes?: Partial<DropdownClasses>` where `DropdownClasses = { root, trigger, triggerLabel, chevron, menu, item, itemIcon, itemLabel, itemDescription, itemShortcut, itemCheck, separator, label }`
394
+
395
+ Keyboard inside any open menu: ArrowUp/ArrowDown move over enabled items (wrapping; labels, separators and disabled items are skipped), Home/End jump, typing a character jumps to the next item starting with it, Enter/Space activate.
354
396
 
355
- `DropdownItemProps`: native `<button>` props plus `disabled?: boolean`.
397
+ `DropdownItemProps` (native `<button>` props plus):
398
+ - `disabled?: boolean` — default `false`.
399
+ - `danger?: boolean` — default `false`. Danger text + tint on hover (Delete, Remove).
400
+ - `icon?: ReactNode` — leading slot (aria-hidden).
401
+ - `shortcut?: ReactNode` — trailing hint (aria-hidden); pass `<Kbd keys={['⌘', 'D']} />`.
402
+ - `description?: ReactNode` — muted second line.
403
+ - `checked?: boolean` — when defined the item is `role="menuitemcheckbox"` with `aria-checked` and a leading check slot (width kept when unchecked).
404
+ - `closeOnSelect?: boolean` — default `true` for action items, `false` for checkable ones.
405
+ - `classes?: Partial<Pick<DropdownClasses, 'item' | 'itemIcon' | 'itemLabel' | 'itemDescription' | 'itemShortcut' | 'itemCheck'>>`.
406
+
407
+ `DropdownSeparator` — `<div role="separator">` hairline. `DropdownLabel` — non-interactive uppercase section heading. Both forward refs and take native div props.
356
408
 
357
- Mode A example:
409
+ `useContextMenu()` → `{ anchor, open, onOpenChange, onContextMenu, openAt(point), close }`. Put `onContextMenu` on the area, the rest on the `Dropdown`.
410
+
411
+ Mode A example (full menu):
358
412
  ```tsx
359
- <Dropdown trigger={<>Menu ▾</>}>
360
- <DropdownItem onClick={onEdit}>Edit</DropdownItem>
361
- <DropdownItem onClick={onDelete}>Delete</DropdownItem>
413
+ <Dropdown trigger="Actions" fullWidth={false}>
414
+ <DropdownLabel>File</DropdownLabel>
415
+ <DropdownItem icon={<PencilIcon />} shortcut={<Kbd size="sm">E</Kbd>} onClick={rename}>Rename</DropdownItem>
416
+ <DropdownItem icon={<CopyIcon />} description="Copy next to the original" onClick={dup}>Duplicate</DropdownItem>
417
+ <DropdownSeparator />
418
+ <DropdownLabel>View</DropdownLabel>
419
+ <DropdownItem checked={view === 'grid'} onClick={() => setView('grid')}>Grid</DropdownItem>
420
+ <DropdownItem checked={showHidden} onClick={() => setShowHidden((v) => !v)}>Show hidden</DropdownItem>
421
+ <DropdownSeparator />
422
+ <DropdownItem icon={<TrashIcon />} danger onClick={remove}>Delete</DropdownItem>
362
423
  </Dropdown>
363
424
  ```
364
425
 
@@ -372,6 +433,17 @@ Mode B example:
372
433
  />
373
434
  ```
374
435
 
436
+ Mode C example (context menu):
437
+ ```tsx
438
+ const menu = useContextMenu();
439
+ <div onContextMenu={menu.onContextMenu}>Right-click me</div>
440
+ <Dropdown anchor={menu.anchor} open={menu.open} onOpenChange={menu.onOpenChange}>
441
+ <DropdownItem onClick={rename}>Rename</DropdownItem>
442
+ <DropdownSeparator />
443
+ <DropdownItem danger onClick={remove}>Delete</DropdownItem>
444
+ </Dropdown>
445
+ ```
446
+
375
447
  ### SplitButton
376
448
  Import: `import { SplitButton } from '@overdoser/react-toolkit'`
377
449
 
@@ -458,7 +530,7 @@ Compound component: `Modal.Header`, `Modal.Body`, `Modal.Footer`. Renders into a
458
530
  - `size?: 'sm' | 'md' | 'lg' | 'fullscreen'` — default `'md'`
459
531
  - `aria-label?: string` — use this OR `aria-labelledby`. If neither is provided, the `Modal.Header` content is auto-wired as the `aria-labelledby` target.
460
532
  - `aria-labelledby?: string`
461
- - `classes?: Partial<ModalClasses>` where `ModalClasses = { backdrop, modal, header, closeButton, body, footer }`
533
+ - `classes?: Partial<ModalClasses>` where `ModalClasses = { backdrop, modal, header, headerTitle, closeButton, body, footer }`
462
534
 
463
535
  Locks body scroll while open; traps focus; restores focus to previously-focused element on close.
464
536
 
@@ -480,6 +552,122 @@ Example:
480
552
  </Modal>
481
553
  ```
482
554
 
555
+ ### CommandPalette
556
+ Import: `import { CommandPalette, useCommandPalette } from '@overdoser/react-toolkit'`
557
+ ⌘K palette: a portaled, top-anchored `role="dialog"` panel (forwards ref) with a `role="combobox"` input over a `role="listbox"` of grouped items. Fuzzy local filtering with `<mark>` highlighting, recent items, nested pages, shortcuts rendered with `Kbd`, async mode. Opens on `hotkey` (`'mod+k'` by default) through `useKeyboard`.
558
+
559
+ `CommandItem = { id: string; label: ReactNode; keywords?: string[]; description?: ReactNode; icon?: ReactNode; shortcut?: string | string[]; group?: string; disabled?: boolean; onSelect?: () => void; href?: string; children?: CommandItem[] }` — string labels are searchable; node labels match through `keywords`. `children` = a nested page (Backspace on an empty query goes back; breadcrumb chip in the header).
560
+
561
+ `CommandPaletteProps`:
562
+ - `open: boolean`, `onOpenChange: (open: boolean) => void` — required (hotkey, Escape, backdrop and selection route through it).
563
+ - `items: CommandItem[]` — required. `onSelect?: (item) => void` — after the item's own `onSelect`. `closeOnSelect?: boolean` — default `true`.
564
+ - `query?` / `defaultQuery?` / `onQueryChange?` — controlled search text.
565
+ - `filter?: ((item, query) => boolean | number) | null` — default fuzzy (word-start substring > substring > subsequence over label + keywords). `null` = remote mode: you pass filtered `items`.
566
+ - `loading?: boolean` + `loadingMessage?` (default `'Searching…'`), `emptyMessage?` (default `'No results'`), `placeholder?` (default `'Type a command or search…'`).
567
+ - `hotkey?: string | false` — default `'mod+k'`.
568
+ - `recentIds?: string[]` + `recentLabel?` (default `'Recent'`) — listed first while the query is empty.
569
+ - `maxResults?: number` — default `50`. `groupOrder?: string[]`. `footer?: ReactNode | null` — default Kbd hints row; `null` hides. `escapeClearsQuery?: boolean` — default `false`. `highlightMatches?: boolean` — default `true`.
570
+ - `renderItem?: (item, { active, query }) => ReactNode`. `aria-label?` — default `'Command palette'`.
571
+ - `classes?: Partial<CommandPaletteClasses>` where `CommandPaletteClasses = { backdrop, panel, header, breadcrumb, input, list, group, groupLabel, item, itemActive, itemIcon, itemLabel, itemDescription, itemShortcut, empty, loading, footer, match }`.
572
+ Keyboard: ArrowUp/Down wrap (skip disabled), Home/End, PageUp/PageDown ±10, Enter selects (`href` items navigate), Escape closes.
573
+ `useCommandPalette(initialOpen = false)` → `{ open, setOpen, toggle, paletteProps: { open, onOpenChange } }`.
574
+
575
+ ```tsx
576
+ const palette = useCommandPalette();
577
+ <CommandPalette {...palette.paletteProps} recentIds={recent}
578
+ items={[
579
+ { id: 'new', label: 'New project', icon: <PlusIcon />, shortcut: ['⌘', 'N'], group: 'Actions', keywords: ['create'], onSelect: create },
580
+ { id: 'settings', label: 'Settings', group: 'Navigate', href: '/settings' },
581
+ { id: 'theme', label: 'Change theme', children: [{ id: 'light', label: 'Light', onSelect: () => setTheme('light') }] },
582
+ ]} />
583
+ // Remote: <CommandPalette … items={results} filter={null} loading={isFetching} query={q} onQueryChange={setQ} />
584
+ ```
585
+
586
+ ### ConfirmDialog / ConfirmProvider / useConfirm
587
+ Import: `import { ConfirmDialog, ConfirmProvider, useConfirm } from '@overdoser/react-toolkit'`
588
+ A confirm dialog built on `Modal size="sm"` (forwards ref to the dialog). Two ways to use it: a controlled component, or the promise API (`await confirm({...})`) which replaces `window.confirm`.
589
+
590
+ `ConfirmDialogProps`:
591
+ - `open: boolean` — required.
592
+ - `onConfirm: () => void | Promise<void>` — required. A returned promise puts the confirm button in `loading` and locks cancel/Escape/backdrop/× until it settles; a rejection (or throw) shows the error under the body and keeps the dialog open. The dialog never closes itself — close it in `onConfirm`/`onCancel`.
593
+ - `onCancel: () => void` — required. Cancel button, Escape, header ×, backdrop (never while pending).
594
+ - `title?: ReactNode` — default `'Are you sure?'`. A string title is also the dialog's accessible name.
595
+ - `description?: ReactNode` — muted body text; `children` renders after it.
596
+ - `confirmLabel?: ReactNode` — default `'Confirm'`. `cancelLabel?: ReactNode` — default `'Cancel'`.
597
+ - `danger?: boolean` — default `false`. Confirm button `variant="danger"`, warning icon, initial focus on Cancel.
598
+ - `requireText?: string` — type-to-confirm: an `Input` ("Type **text** to confirm") must match exactly before the confirm button enables; Enter in it confirms.
599
+ - `icon?: ReactNode | false` — default: warning triangle when `danger`, none otherwise.
600
+ - `autoFocus?: 'confirm' | 'cancel'` — default `'cancel'` when `danger`, else `'confirm'` (the input wins when `requireText` is set).
601
+ - `closeOnBackdrop?: boolean` — default `true`.
602
+ - `errorMessage?: (err: unknown) => ReactNode` — default `String(err?.message ?? err)`.
603
+ - `aria-label?: string` — used when there is no string title.
604
+ - `classes?: Partial<ConfirmDialogClasses>` where `ConfirmDialogClasses = { modal, header, body, description, icon, input, error, footer, cancel, confirm }`.
605
+
606
+ `ConfirmProvider` (`children`, `defaults?: Partial<ConfirmOptions>`) mounts one dialog near the app root. `useConfirm(): ConfirmFn` where `ConfirmFn = (options?: ConfirmOptions) => Promise<boolean>` and `ConfirmOptions = Omit<ConfirmDialogProps, 'open' | 'onConfirm' | 'onCancel' | 'children'> & { body?: ReactNode; onConfirm?: () => void | Promise<void> }`. Resolves `true` after confirm (and after an async `onConfirm` resolves — the dialog then closes), `false` on cancel/Escape/backdrop. Calling `confirm()` while one is open resolves the previous one `false`. Throws outside a provider.
607
+
608
+ ```tsx
609
+ // Promise API (preferred)
610
+ <ConfirmProvider>{app}</ConfirmProvider>
611
+ const confirm = useConfirm();
612
+ if (await confirm({ title: 'Delete project?', description: 'This cannot be undone.', danger: true, confirmLabel: 'Delete', onConfirm: () => api.remove(id) })) {
613
+ toast({ variant: 'success', title: 'Deleted' });
614
+ }
615
+
616
+ // Controlled
617
+ <ConfirmDialog open={open} danger title="Delete project?" confirmLabel="Delete" requireText={project.slug}
618
+ onConfirm={async () => { await api.remove(id); setOpen(false); }} onCancel={() => setOpen(false)} />
619
+ ```
620
+
621
+ ### ImageViewer
622
+ Import: `import { ImageViewer, useZoomPan } from '@overdoser/react-toolkit'`
623
+ Lightbox: a portaled `<div role="dialog" aria-modal>` (forwards ref) with a dark stage, prev/next, counter, optional thumbnail strip, zoom/pan (wheel toward the cursor, pinch, double-click, keyboard `+`/`-`/`0`), caption and download. Focus trap, body scroll lock, Escape (through the overlay stack), ArrowLeft/Right, swipe at scale 1, neighbour preloading. `useZoomPan` is the zero-dependency zoom/pan engine if you need it elsewhere.
624
+
625
+ `ImageViewerProps`:
626
+ - `open: boolean`, `onClose: () => void` — required (close button, Escape, backdrop).
627
+ - `items: { src: string; alt?: string; thumbnail?: string; caption?: ReactNode; download?: string | boolean }[]` — required (`download: true` = `src`).
628
+ - `index?: number` (controlled) / `defaultIndex?: number` (default `0`) / `onIndexChange?: (i: number) => void`.
629
+ - `loop?: boolean` — default `true` (when `false` the end buttons are hidden).
630
+ - `showCounter?: boolean` — default `true` ("3 / 12"; hidden for one item). `showThumbnails?: boolean` — default `false`. `showZoomControls?: boolean` — default `true`. `showDownload?: boolean` — default: when the item has `download`.
631
+ - `renderSlide?: (item, { index, active }) => ReactNode` — replace the `<img>` (video, canvas); the node is zoomed/panned like an image.
632
+ - `closeOnBackdrop?: boolean` — default `true` (a drag doesn't close).
633
+ - `zoom?: Partial<UseZoomPanOptions>` — `{ minScale: 1, maxScale: 8, step: 0.5, wheel: true, doubleClickToggle: true }`.
634
+ - `labels?: Partial<{ viewer, close, previous, next, zoomIn, zoomOut, reset, fit, download, loading }>`.
635
+ - `classes?: Partial<ImageViewerClasses>` where `ImageViewerClasses = { root, backdrop, toolbar, counter, stage, image, caption, nav, navPrev, navNext, thumbnails, thumbnail, thumbnailActive, zoomControls }`.
636
+ CSS vars: `--crk-image-viewer-backdrop`, `--crk-image-viewer-control-bg`, `--crk-image-viewer-control-bg-hover`, `--crk-image-viewer-control-color`, `--crk-image-viewer-control-size`.
637
+
638
+ `useZoomPan(options)` → `{ scale, x, y, isPanning, stageProps, contentRef, contentStyle, zoomIn, zoomOut, zoomTo, reset, fit }`. Spread `stageProps` on a `position: relative; overflow: hidden` stage and `contentStyle` on the zoomed element.
639
+
640
+ ```tsx
641
+ <ImageViewer open={open} onClose={() => setOpen(false)} index={index} onIndexChange={setIndex} showThumbnails
642
+ items={photos.map((p) => ({ src: p.url, thumbnail: p.thumb, alt: p.title, caption: p.title, download: true }))} />
643
+ ```
644
+
645
+ ### SplitPane
646
+ Import: `import { SplitPane } from '@overdoser/react-toolkit'`
647
+ Element: `<div>` (forwards ref) with two panes and a `role="separator"` handle between them. Drag + keyboard resizable split (sidebar/editor, editor/terminal), optional collapse and persisted size. The engine is the `useResizable` hook (exported) if you need a custom resizable panel.
648
+
649
+ `SplitPaneProps` (extends div props minus `children`):
650
+ - `children: [ReactNode, ReactNode]` — required.
651
+ - `direction?: 'horizontal' | 'vertical'` — default `'horizontal'` (side by side; vertical = stacked).
652
+ - `primary?: 'first' | 'second'` — default `'first'`; the pane that gets the size, the other flexes.
653
+ - `size?: number | string` (controlled: px number or `'30%'`) / `defaultSize?` — default `'50%'` (a percentage keeps its ratio on container resize until the user drags) / `onSizeChange?: (px: number) => void`.
654
+ - `minSize?: number` — default `100`. `maxSize?: number` — default container − `minSecondarySize` − handle. `minSecondarySize?: number` — default `100`.
655
+ - `collapsible?: boolean` — default `false`: dragging below `minSize / 2` or double-clicking the handle collapses the primary pane to 0. `collapsed?` / `defaultCollapsed?` / `onCollapsedChange?`.
656
+ - `persistKey?: string` — persists `{ px, collapsed }` in localStorage via `usePersistedState`.
657
+ - `handleSize?: number` — default `6` (hit area; visible line 1px, 3px on hover/drag). `handleLabel?: string` — default `'Resize'`. `disabled?: boolean`.
658
+ - `classes?: Partial<SplitPaneClasses>` where `SplitPaneClasses = { root, pane, primary, secondary, handle, handleActive, collapsed }`.
659
+ Handle a11y: `aria-orientation`, `aria-valuenow/min/max`; Arrow keys ±16px (Shift ×10), Home/End, double-click resets. CSS vars: `--crk-splitpane-handle-color`, `--crk-splitpane-handle-hover`, `--crk-splitpane-handle-size`.
660
+
661
+ ```tsx
662
+ <SplitPane defaultSize={280} minSize={200} collapsible persistKey="layout:sidebar" handleLabel="Resize sidebar">
663
+ <Sidebar />
664
+ <SplitPane direction="vertical" defaultSize="65%" minSize={80}>
665
+ <Editor />
666
+ <Terminal />
667
+ </SplitPane>
668
+ </SplitPane>
669
+ ```
670
+
483
671
  ### Draggable
484
672
  Import: `import { Draggable } from '@overdoser/react-toolkit'`
485
673
  Element: a `<div>` (forwards ref) that wraps arbitrary children. Free-move container — position is a `translate(x, y)` offset from the element's natural layout position, so it stays in flow until dragged.
@@ -579,20 +767,186 @@ Example:
579
767
 
580
768
  ### Alert
581
769
  Import: `import { Alert } from '@overdoser/react-toolkit'`
582
- Element: a `<div role="alert">` (forwards ref). Inline, persistent status message.
770
+ Element: a `<div role="alert">` (forwards ref; pass `role="status"` for non-urgent info). Inline, persistent status message — or a full-width page banner.
583
771
 
584
772
  `AlertProps` (extends native `div` props, omits `title`):
585
773
  - `variant?: 'info' | 'success' | 'warning' | 'danger'` — default `'info'`.
586
774
  - `title?: ReactNode` — optional bold heading.
587
775
  - `icon?: ReactNode | boolean` — default `true` (variant icon). Pass a node to override, `false` to hide.
776
+ - `action?: ReactNode` — slot after the message (Retry / Undo / View). Inline: wraps under the text on narrow widths. Banner: pushed to the right edge, before the close button.
777
+ - `layout?: 'inline' | 'banner'` — default `'inline'`. `banner` = full-width strip (no radius, no side accent, one row: icon · text · action · close) for the top of a page/app shell.
778
+ - `size?: 'sm' | 'md'` — default `'md'`. `sm` tightens padding and uses font-size sm (hints inside forms/cards).
588
779
  - `onClose?: () => void` — when set, renders a dismiss button.
589
780
  - `closeLabel?: string` — default `'Dismiss'`.
590
- - `classes?: Partial<AlertClasses>` where `AlertClasses = { root, icon, content, title, message, close }`.
781
+ - `classes?: Partial<AlertClasses>` where `AlertClasses = { root, icon, content, title, message, action, close }`.
591
782
  - children = message body.
592
783
 
593
784
  Example:
594
785
  ```tsx
595
786
  <Alert variant="success" title="Saved" onClose={() => setShown(false)}>Your changes were saved.</Alert>
787
+ <Alert variant="danger" title="Couldn't save" action={<Button size="sm" variant="secondary" onClick={retry}>Retry</Button>}>The server did not respond.</Alert>
788
+ <Alert layout="banner" variant="warning" action={<Button size="sm">Renew now</Button>} onClose={dismiss}>Your trial ends in 3 days.</Alert>
789
+ ```
790
+
791
+ ### CodeBlock / Code
792
+ Import: `import { CodeBlock, Code } from '@overdoser/react-toolkit'`
793
+ `CodeBlock`: a `<div>` root (forwards ref) around `<pre><code>` with a built-in copy button, optional header (title + language), line numbers, wrap toggle and max height. No highlighter dependency — `highlight` lets you plug one in. `Code`: inline `<code>` (forwards ref; `classes?: { root }`).
794
+
795
+ `CodeBlockProps` (extends native `div` props minus `children`/`title`):
796
+ - `code?: string` — the source; exactly what the copy button copies (trailing newline trimmed for display). `children?: string` is an alias; `code` wins.
797
+ - `language?: string` — header label (right); also `data-language` + `language-<x>` class on `<code>` for CSS highlighters.
798
+ - `title?: ReactNode` — header text (left), e.g. a filename.
799
+ - `showCopy?: boolean` — default `true`. `copyPlacement?: 'floating' | 'header'` — default `'floating'` (top-right over the code, visible on hover / focus-within) or in the header row. `onCopied?: (text: string) => void`.
800
+ - `wrap?: boolean` — default `false` (horizontal scroll). `showWrapToggle?: boolean` — default `false`; header button (`aria-pressed`) that flips wrap locally.
801
+ - `lineNumbers?: boolean` — default `false`. `startLine?: number` — default `1`. `highlightLines?: number[]` — absolute displayed line numbers to tint.
802
+ - `maxHeight?: number | string` — vertical scroll on the `<pre>`.
803
+ - `size?: 'sm' | 'md'` — default `'md'`.
804
+ - `highlight?: (code: string) => ReactNode` — plug-in highlighter (whole text, or per line when `lineNumbers`).
805
+ - `classes?: Partial<CodeBlockClasses>` where `CodeBlockClasses = { root, header, title, language, actions, pre, code, line, lineNumber, lineHighlight, copy, wrapToggle }`.
806
+ The header row renders when `title`, `language`, `showWrapToggle`, or `copyPlacement="header"`. CSS vars: `--crk-code-font-family`, `--crk-code-bg`, `--crk-code-color`, `--crk-code-border`, `--crk-code-radius`, `--crk-code-padding`, `--crk-code-font-size`, `--crk-code-highlight-bg`, `--crk-code-gutter-color`.
807
+
808
+ ```tsx
809
+ <CodeBlock language="bash" code="npm install @overdoser/react-toolkit" />
810
+ <CodeBlock title="PlanCard.tsx" language="tsx" copyPlacement="header" lineNumbers highlightLines={[5, 6]} showWrapToggle code={src} />
811
+ <p>Run <Code>npm test</Code> after every change.</p>
812
+ ```
813
+
814
+ ### SegmentedControl
815
+ Import: `import { SegmentedControl } from '@overdoser/react-toolkit'`
816
+ Element: `<div role="radiogroup">` (forwards ref); items are `<button role="radio" aria-checked>` with roving tabindex. Single-select button group — the "pill tabs without panels" pattern (view switcher, period picker, filter mode). For a multi-select version use `CheckboxGroup variant="chips"`. When any option has `href`, the root is `role="group"` and items are `<a>` with `aria-current="page"` on the selected one.
817
+
818
+ `SegmentedControlProps<T extends string>`:
819
+ - `options: { value: T; label?: ReactNode; icon?: ReactNode; disabled?: boolean; tooltip?: ReactNode; count?: number | string; href?: string; 'aria-label'?: string }[]` — required. `icon` without `label` = icon-only (a string `tooltip` also names it). `count` = small muted counter.
820
+ - `value?: T` (controlled) / `defaultValue?: T` / `onChange?: (value: T) => void` (not fired when re-selecting the current value).
821
+ - `size?: 'sm' | 'md' | 'lg'` — default `'md'`. `shape?: 'pill' | 'rounded' | 'square'` — default `'rounded'`.
822
+ - `variant?: 'filled' | 'outlined'` — default `'filled'` (grey track, raised white selected segment) / outlined = joined bordered buttons, selected = primary-light.
823
+ - `fullWidth?: boolean` — default `false` (equal-width segments). `disabled?: boolean`.
824
+ - `aria-label` / `aria-labelledby` — label the group.
825
+ - `classes?: Partial<SegmentedControlClasses>` where `SegmentedControlClasses = { root, item, itemSelected, icon, label, count }`.
826
+ Keyboard: ArrowLeft/Right/Up/Down move selection + focus (wrap, skip disabled); Home/End. CSS vars: `--crk-segmented-track-bg`, `--crk-segmented-selected-bg`, `--crk-segmented-selected-color`, `--crk-segmented-radius`, `--crk-segmented-gap`.
827
+
828
+ ```tsx
829
+ <SegmentedControl aria-label="View" value={view} onChange={setView}
830
+ options={[{ value: 'list', label: 'List', icon: <ListIcon /> }, { value: 'grid', label: 'Grid', count: 12 }]} />
831
+ <SegmentedControl aria-label="Period" size="sm" shape="pill" value={p} onChange={setP} options={[{ value: '1d', label: '1D' }, { value: '1w', label: '1W' }, { value: '1m', label: '1M' }]} />
832
+ ```
833
+
834
+ ### Chip / ChipGroup
835
+ Import: `import { Chip, ChipGroup } from '@overdoser/react-toolkit'`
836
+ `Chip` is the *interactive* tag (removable, toggleable, clickable); `Badge` stays the read-only status pill. Element: `<button>` when clickable/toggle without `onRemove`; `<span role="button" tabIndex=0>` when clickable *and* removable (the × is the only real button inside); plain `<span>` otherwise. Forwards ref.
837
+
838
+ `ChipProps` (extends button props minus `color`/`type`):
839
+ - `children` — label (a string is appended to the remove button's aria-label).
840
+ - `icon?: ReactNode` — leading. `avatar?: ReactNode` — leading round slot (`<Avatar size="xs" />`).
841
+ - `onRemove?: () => void` — trailing × button (`aria-label` "Remove <label>"); Backspace/Delete on the focused chip also removes. `removeLabel?: string` — default `'Remove'`.
842
+ - `selected?: boolean` — when defined the chip is a toggle (`aria-pressed`, solid fill + leading check mark with constant width). `onSelectedChange?: (next: boolean) => void`.
843
+ - `onClick?` — makes it clickable. `disabled?: boolean` — default `false`.
844
+ - `color?: 'neutral' | 'primary' | 'success' | 'warning' | 'danger'` — default `'neutral'`. `appearance?: 'soft' | 'outline'` — default `'soft'`.
845
+ - `size?: 'sm' | 'md'` — default `'md'`. `shape?: 'pill' | 'rounded'` — default `'pill'`.
846
+ - `classes?: Partial<ChipClasses>` where `ChipClasses = { root, icon, avatar, label, remove }`.
847
+
848
+ `ChipGroupProps` (`<div role="group">`, forwards ref, extends div props): `max?: number` (show at most N, then a "+N" overflow chip), `overflowLabel?: (hidden: number) => ReactNode` (default `+N`), `onOverflowClick?: () => void` (makes the overflow chip a button), `expandable?: boolean` (default `false`; "+N" reveals all, a trailing `collapseLabel` chip — default `'Show less'` — collapses), `gap?: 'sm' | 'md'` (default `'sm'`), `wrap?: boolean` (default `true`), `classes?: { root, overflow }`.
849
+
850
+ ```tsx
851
+ <Chip onRemove={() => remove(tag)}>{tag}</Chip>
852
+ <Chip selected={active} onSelectedChange={setActive} color="primary">Open</Chip>
853
+ <ChipGroup max={3} expandable aria-label="Labels">{tags.map((t) => <Chip key={t}>{t}</Chip>)}</ChipGroup>
854
+ ```
855
+
856
+ ### PageHeader
857
+ Import: `import { PageHeader } from '@overdoser/react-toolkit'`
858
+ Element: `<header>` (forwards ref). The top-of-page block every admin page repeats: breadcrumbs, back link, title + badge, subtitle/description/meta, right-aligned actions, optional tabs flush with the bottom border.
859
+
860
+ `PageHeaderProps` (extends native `header` props minus `title`):
861
+ - `title: ReactNode` — required. `as?: 'h1' | 'h2' | 'h3' | 'div'` — default `'h1'`.
862
+ - `subtitle?: ReactNode` (muted line), `description?: ReactNode` (paragraph, max-width 70ch), `meta?: ReactNode` (small muted row: "Updated 3 min ago · 12 members"), `badge?: ReactNode` (inline after the title — `<Badge>` / `<StatusDot>`).
863
+ - `actions?: ReactNode` — right-aligned slot; wraps under on narrow widths.
864
+ - `breadcrumbs?: ReactNode` — slot above the title (pass `<Breadcrumbs>`).
865
+ - `backHref?: string` / `onBack?: () => void` / `backLabel?: string` (default `'Back'`) — "← Back" link (href) or button (onBack).
866
+ - `tabs?: ReactNode` — bottom slot for `<Tabs.List>`; removes the bottom padding.
867
+ - `divider?: boolean` — default `true`. `size?: 'sm' | 'md' | 'lg'` — default `'md'` (title xl / 2xl / 3xl). `sticky?: boolean` — default `false`.
868
+ - `children?` — rendered after the title row, before `tabs`.
869
+ - `classes?: Partial<PageHeaderClasses>` where `PageHeaderClasses = { root, breadcrumbs, back, titleRow, title, badge, subtitle, description, meta, actions, tabs }`.
870
+
871
+ ```tsx
872
+ <PageHeader title="Payments API" badge={<Badge variant="success" dot>Healthy</Badge>} subtitle="Production"
873
+ breadcrumbs={<Breadcrumbs>…</Breadcrumbs>} onBack={goBack} meta={<>Updated <RelativeTime value={updatedAt} /> · 12 members</>}
874
+ actions={<Button>Deploy</Button>} tabs={<Tabs.List>…</Tabs.List>} />
875
+ ```
876
+
877
+ ### Accordion (Accordion.Item / Accordion.Trigger / Accordion.Content)
878
+ Import: `import { Accordion } from '@overdoser/react-toolkit'`
879
+ Disclosure list (FAQ, settings sections, collapsible panels). Root `<div>` (forwards ref); each trigger is a `<button aria-expanded aria-controls>` inside a heading; content is `<div role="region" aria-labelledby>`. Height animates via `grid-template-rows` (no measuring); reduced motion respected.
880
+
881
+ `AccordionProps` (extends div props minus `onChange`):
882
+ - `type?: 'single' | 'multiple'` — default `'single'`.
883
+ - `value?: string | string[]` / `defaultValue?` / `onValueChange?: (value: string | string[]) => void` — string in single mode (`''` when all closed), array in multiple.
884
+ - `collapsible?: boolean` — default `true` (single mode: clicking the open item closes it).
885
+ - `keepMounted?: boolean` — default `false` (closed content unmounted); `true` keeps it mounted with `hidden`.
886
+ - `variant?: 'default' | 'bordered' | 'separated'` — default `'default'` (hairlines / outer border + radius / each item its own bordered card).
887
+ - `size?: 'sm' | 'md'` — default `'md'`. `disabled?: boolean`. `headingLevel?: 2 | 3 | 4` — default `3`.
888
+ - `items?: { value: string; title: ReactNode; content: ReactNode; disabled?: boolean }[]` — data shorthand instead of children.
889
+ - `classes?: Partial<AccordionClasses>` where `AccordionClasses = { root, item, itemOpen, header, trigger, icon, content, contentInner }`.
890
+ `Accordion.Item`: `value: string` (required), `disabled?`. `Accordion.Trigger`: `icon?: ReactNode | false` (default chevron, rotates when open), `iconPosition?: 'start' | 'end'` (default `'end'`). `Accordion.Content`: children.
891
+ Keyboard on triggers: ArrowUp/ArrowDown (wrap, skip disabled), Home/End; Enter/Space toggle.
892
+
893
+ ```tsx
894
+ <Accordion defaultValue="shipping" variant="bordered">
895
+ <Accordion.Item value="shipping">
896
+ <Accordion.Trigger>Shipping</Accordion.Trigger>
897
+ <Accordion.Content>Orders ship within 2 business days.</Accordion.Content>
898
+ </Accordion.Item>
899
+ <Accordion.Item value="returns"><Accordion.Trigger>Returns</Accordion.Trigger><Accordion.Content>30-day window.</Accordion.Content></Accordion.Item>
900
+ </Accordion>
901
+ <Accordion type="multiple" items={faq} />
902
+ ```
903
+
904
+ ### KeyValueList
905
+ Import: `import { KeyValueList } from '@overdoser/react-toolkit'`
906
+ Element: `<dl>` (forwards ref); each item is `<div><dt>label</dt><dd>value</dd></div>`. Label/value rows for detail panels (profile, request headers, config) — with copy, masked secrets, links and hints built in.
907
+
908
+ `KeyValueListProps` (extends native `dl` props minus `children`):
909
+ - `items: KeyValueItem[]` — required. `KeyValueItem = { key?: string; label: ReactNode; value: ReactNode; copyable?: boolean | string; mono?: boolean; masked?: boolean; href?: string; hint?: ReactNode; empty?: ReactNode }`. `copyable: true` copies a string/number value; a string copies that exact text. `masked` renders `••••••••` with an eye toggle (copy still copies the real value). `href` wraps the value in a link. `hint` = muted second line.
910
+ - `layout?: 'rows' | 'grid' | 'inline'` — default `'rows'` (label left / value right, one per line) · `'grid'` (label above value, `columns?: number`, default `2`) · `'inline'` (`label: value` pairs flowing and wrapping — metadata strips).
911
+ - `labelWidth?: number | string` — default `'10rem'` (rows; number → px).
912
+ - `size?: 'sm' | 'md'` — default `'md'`. `dividers?: boolean` — default `true` (rows only).
913
+ - `emptyValue?: ReactNode` — default `'—'` for null / undefined / `''`.
914
+ - `copyLabel?: string` — default `'Copy'`. `revealLabels?: { show: string; hide: string }` — default Show / Hide.
915
+ - `classes?: Partial<KeyValueListClasses>` where `KeyValueListClasses = { root, item, label, value, hint, actions, copy, reveal, mono, masked }`.
916
+
917
+ ```tsx
918
+ <KeyValueList items={[
919
+ { label: 'User ID', value: 'usr_8f3a', mono: true, copyable: true },
920
+ { label: 'Email', value: 'ada@example.com', href: 'mailto:ada@example.com' },
921
+ { label: 'API key', value: key, masked: true, copyable: true, hint: 'Rotated 2 days ago' },
922
+ { label: 'Phone', value: null },
923
+ ]} />
924
+ <KeyValueList layout="grid" columns={3} items={…} />
925
+ ```
926
+
927
+ ### StatCard / StatGrid
928
+ Import: `import { StatCard, StatGrid } from '@overdoser/react-toolkit'`
929
+ KPI tile: caption, big value, delta with trend colour, optional icon / sparkline / footer. `StatGrid` lays tiles out responsively. `StatCard` element: `<div>` (or `<a>` with `href`; `role="button"` + keyboard with `onClick`), forwards ref, `aria-busy` while loading.
930
+
931
+ `StatCardProps` (extends div props minus `title`):
932
+ - `label: ReactNode` — required. `value: ReactNode` — required (format it yourself). `unit?: ReactNode` — smaller suffix.
933
+ - `delta?: number | { value: ReactNode; trend?: 'up' | 'down' | 'flat' }` — a number renders `▲ 12.5%` / `▼ 3%` with the trend from its sign; an object is pre-formatted text + explicit trend.
934
+ - `deltaFormat?: (n: number) => ReactNode` — default `Intl.NumberFormat` (max 1 decimal) + `%`.
935
+ - `trendColor?: 'auto' | 'positive-up' | 'positive-down' | 'none'` — default `'auto'` (= up green, down red); `'positive-down'` for latency / cost / errors.
936
+ - `deltaLabel?: ReactNode` — muted text after the delta ("vs last week").
937
+ - `icon?: ReactNode` (top-right), `chart?: ReactNode` (bottom — `<Sparkline>`), `footer?: ReactNode`.
938
+ - `href?: string`, `onClick?`, `loading?: boolean` (value + delta → Skeleton bars).
939
+ - `variant?: 'outlined' | 'elevated' | 'filled'` — default `'outlined'`. `size?: 'sm' | 'md' | 'lg'` — default `'md'`. `accent?: string` — left stripe colour.
940
+ - `classes?: Partial<StatCardClasses>` where `StatCardClasses = { root, header, label, icon, value, unit, delta, deltaLabel, chart, footer }`.
941
+ `StatGridProps`: `columns?: number | { sm?: number; md?: number; lg?: number }` — default `{ sm: 1, md: 2, lg: 4 }` (breakpoints 640 / 1024px), `gap?: 'sm' | 'md' | 'lg'` — default `'md'`, `classes?: { root }`.
942
+
943
+ ```tsx
944
+ <StatGrid>
945
+ <StatCard label="Revenue" value="€48.2k" delta={12.5} deltaLabel="vs last month" accent="var(--crk-color-success)" />
946
+ <StatCard label="p95 latency" value={412} unit="ms" delta={-8} trendColor="positive-down" />
947
+ <StatCard label="Signups" value={27} delta={{ value: '+5 today', trend: 'up' }} chart={<Sparkline data={series} />} />
948
+ <StatCard label="Orders" value={318} loading />
949
+ </StatGrid>
596
950
  ```
597
951
 
598
952
  ### Badge
@@ -612,6 +966,145 @@ Example:
612
966
  <Badge variant="primary" appearance="solid">3</Badge>
613
967
  ```
614
968
 
969
+ ### StatusDot
970
+ Import: `import { StatusDot } from '@overdoser/react-toolkit'`
971
+ Element: a `<span>` (forwards ref). Coloured status indicator dot with optional label (online/offline, healthy/degraded, saving/saved). The dot is `aria-hidden`; pass `label` or `aria-label` (which sets `role="img"`).
972
+
973
+ `StatusDotProps` (extends native `span` props, `color` retyped):
974
+ - `status?: 'success' | 'warning' | 'danger' | 'info' | 'neutral'` — default `'neutral'`. `info` = primary colour, `neutral` = text-muted.
975
+ - `pulse?: boolean` — default `false`. Expanding ring animation (off under `prefers-reduced-motion`).
976
+ - `label?: ReactNode` — text after the dot.
977
+ - `size?: 'sm' | 'md' | 'lg'` — default `'md'` (dot 0.5 / 0.625 / 0.75rem).
978
+ - `color?: string` — any CSS colour; overrides the status colour (`--crk-status-dot-color`).
979
+ - `classes?: Partial<StatusDotClasses>` where `StatusDotClasses = { root, dot, label }`.
980
+
981
+ ```tsx
982
+ <StatusDot status="success" label="Online" />
983
+ <StatusDot status="warning" pulse aria-label="Saving" />
984
+ ```
985
+
986
+ ### ThemeToggle
987
+ Import: `import { ThemeToggle } from '@overdoser/react-toolkit'`
988
+ Element: `<button>` (icon variant, forwards ref) or `<div role="radiogroup">` (segmented). Switches the toolkit theme via `useTheme` — see **Dark mode** under Setup.
989
+
990
+ `ThemeToggleProps` (extends button props):
991
+ - `variant?: 'icon' | 'segmented'` — default `'icon'` (sun / moon / monitor icon cycling light → dark → system, `aria-label` "Theme: Light, switch to Dark") or three `role="radio"` buttons.
992
+ - `allowSystem?: boolean` — default `true`; `false` = two states.
993
+ - `size?: 'sm' | 'md'` — default `'md'`. `showLabel?: boolean` — default `false`.
994
+ - `labels?: Partial<Record<'light' | 'dark' | 'system', string>>`. `storageKey?: string` — default `'crk-theme'`.
995
+ - `classes?: Partial<ThemeToggleClasses>` where `ThemeToggleClasses = { root, icon, label, option, optionSelected }`.
996
+
997
+ ```tsx
998
+ <ThemeToggle />
999
+ <ThemeToggle variant="segmented" showLabel />
1000
+ ```
1001
+
1002
+ ### Kbd
1003
+ Import: `import { Kbd } from '@overdoser/react-toolkit'`
1004
+ Element: a `<kbd>` (forwards ref). Keyboard key cap for shortcut hints (menus, help dialogs, tooltips).
1005
+
1006
+ `KbdProps` (extends native `kbd` props):
1007
+ - `size?: 'sm' | 'md'` — default `'md'`.
1008
+ - `keys?: string[]` — a combination: each entry becomes its own inner `<kbd>`, joined by an `aria-hidden` `+` (reads "⌘+K"). When set, `children` is ignored.
1009
+ - `classes?: Partial<KbdClasses>` where `KbdClasses = { root, key, separator }`.
1010
+
1011
+ ```tsx
1012
+ <Kbd>Esc</Kbd>
1013
+ <Kbd keys={['⌘', 'K']} />
1014
+ ```
1015
+
1016
+ ### EmptyState
1017
+ Import: `import { EmptyState } from '@overdoser/react-toolkit'`
1018
+ Element: a `<div>` (forwards ref). Centered placeholder for empty lists, no-results and load errors. Use it as `Table`'s `emptyMessage` too.
1019
+
1020
+ `EmptyStateProps` (extends native `div` props minus `title`):
1021
+ - `variant?: 'empty' | 'error'` — default `'empty'`. `'error'` sets `role="alert"` and a danger-coloured icon.
1022
+ - `icon?: ReactNode | false` — default: a built-in inline SVG per variant (tray / warning triangle). `false` hides it.
1023
+ - `title?: ReactNode`, `description?: ReactNode` (text-secondary, max-width 36ch).
1024
+ - `action?: ReactNode` — slot under the description; pass a `Button` ("Retry", "New project").
1025
+ - `children?: ReactNode` — extra content between description and action.
1026
+ - `size?: 'sm' | 'md' | 'lg'` — default `'md'`. Scales icon, title and padding.
1027
+ - `bordered?: boolean` — default `false`. Dashed frame with subtle background.
1028
+ - `classes?: Partial<EmptyStateClasses>` where `EmptyStateClasses = { root, icon, title, description, action }`.
1029
+ CSS vars: `--crk-empty-state-icon-size`, `--crk-empty-state-icon-color`.
1030
+
1031
+ ```tsx
1032
+ <EmptyState title="No projects yet" description="Create your first project." action={<Button>New project</Button>} />
1033
+ <EmptyState variant="error" title="Couldn't load projects" action={<Button variant="secondary" onClick={refetch}>Retry</Button>} />
1034
+ ```
1035
+
1036
+ ### ProgressBar
1037
+ Import: `import { ProgressBar } from '@overdoser/react-toolkit'`
1038
+ Element: a `<div>` root (forwards ref); the track is `role="progressbar"` with `aria-valuemin/max/now` (`valuenow` omitted when indeterminate). A string `label` doubles as the track's `aria-label`; explicit `aria-label` / `aria-labelledby` are forwarded to the track.
1039
+
1040
+ `ProgressBarProps` (extends native `div` props minus `children`):
1041
+ - `value?: number` — clamped to `[0, max]`. Omit for indeterminate (sliding shimmer; fades instead under reduced motion).
1042
+ - `max?: number` — default `100`.
1043
+ - `label?: ReactNode` — text above the bar (left).
1044
+ - `showValue?: boolean` — default `false`. Formatted value above the bar (right); ignored when indeterminate.
1045
+ - `formatValue?: (value: number, max: number) => ReactNode` — default `"42%"`.
1046
+ - `size?: 'sm' | 'md' | 'lg'` — default `'md'` (track 0.25 / 0.5 / 0.75rem).
1047
+ - `variant?: 'primary' | 'success' | 'warning' | 'danger' | 'neutral'` — default `'primary'`.
1048
+ - `thresholds?: { value: number; variant: ProgressBarVariant }[]` — colour by value: the entry with the highest `value <= current` wins; below all of them `variant` applies. Battery/quota pattern.
1049
+ - `segments?: number` — when `> 1`, N discrete blocks filled from the left (`round(value / max * segments)`); wizard-step progress.
1050
+ - `showCurrent?: boolean` — default `false`. Segmented only: the block after the last filled one gets a mid shade → three states (done / current / remaining; `value` = steps completed).
1051
+ - `shape?: 'rounded' | 'square'` — default `'rounded'`. `'square'` removes every radius (flat survey/wizard strip).
1052
+ - `classes?: Partial<ProgressBarClasses>` where `ProgressBarClasses = { root, header, label, value, track, fill, segment, segmentFilled, segmentCurrent }`.
1053
+ CSS vars: `--crk-progress-fill`, `--crk-progress-track`, `--crk-progress-height`.
1054
+
1055
+ ```tsx
1056
+ <ProgressBar label="Uploading" value={42} showValue />
1057
+ <ProgressBar value={level} thresholds={[{ value: 0, variant: 'danger' }, { value: 20, variant: 'warning' }, { value: 50, variant: 'success' }]} />
1058
+ <ProgressBar value={2} max={5} segments={5} size="lg" />
1059
+ <ProgressBar value={2} max={4} segments={4} showCurrent shape="square" aria-label="Step 3 of 4" /> // done · current · remaining
1060
+ <ProgressBar label="Working…" /> // indeterminate
1061
+ ```
1062
+
1063
+ ### Card (Card.Header / Card.Title / Card.Body / Card.Footer)
1064
+ Import: `import { Card } from '@overdoser/react-toolkit'`
1065
+ Element: a `<div>` — or an `<a>` when `href` is set (forwards ref). Surface container with optional header/body/footer slots that own the padding.
1066
+
1067
+ `CardProps` (extends native `div` props; `href`, `target`, `rel` for the anchor case):
1068
+ - `variant?: 'outlined' | 'elevated' | 'filled'` — default `'outlined'` (border / shadow / subtle background).
1069
+ - `padding?: 'none' | 'sm' | 'md' | 'lg'` — default `'md'`. Sets `--crk-card-padding` used by the slots.
1070
+ - `interactive?: boolean` — default `false`. Hover lift, pointer, focus ring. With `onClick` and no `href` the card becomes a keyboard-operable `role="button"` (Enter/Space). Implied by `href`.
1071
+ - `selected?: boolean` — default `false`. Primary border + ring, `data-selected`; `aria-pressed` in the button case.
1072
+ - `accent?: string` — 3px left stripe in that CSS colour (`'var(--crk-color-success)'` works).
1073
+ - `classes?: Partial<CardClasses>` where `CardClasses = { root, header, title, subtitle, actions, body, footer }`.
1074
+
1075
+ `Card.Header`: `title?`, `subtitle?`, `actions?` (right-aligned slot), `divider?: boolean`, `children?`. `Card.Title`: `as?: 'h2' | 'h3' | 'h4' | 'div'` (default `'h3'`). `Card.Body`: div. `Card.Footer`: `align?: 'start' | 'end' | 'between'` (default `'end'`), `divider?: boolean`.
1076
+ A Body after a Header (or a Footer after a Body/Header) drops its top padding unless the preceding slot has `divider`, so slots never double up.
1077
+
1078
+ ```tsx
1079
+ <Card interactive selected={id === current} onClick={() => select(id)} accent="var(--crk-color-success)">
1080
+ <Card.Header title="Plan" subtitle="Billed yearly" actions={<Badge>Popular</Badge>} />
1081
+ <Card.Body>€9 / month</Card.Body>
1082
+ <Card.Footer><Button size="sm">Choose</Button></Card.Footer>
1083
+ </Card>
1084
+ <Card href="/docs"><Card.Body>Whole card is a link</Card.Body></Card>
1085
+ ```
1086
+
1087
+ ### RelativeTime
1088
+ Import: `import { RelativeTime } from '@overdoser/react-toolkit'`
1089
+ Element: a `<time>` (forwards ref) with `dateTime` set and the absolute time as `title`. "3 minutes ago" / "in 2 hours" via `Intl.RelativeTimeFormat` (no locale tables shipped). Live-updating: one shared timer per tick period across all instances.
1090
+
1091
+ `RelativeTimeProps` (extends native `time` props minus `children`/`title`):
1092
+ - `value: Date | number | string` — the instant (Date, epoch ms, ISO string).
1093
+ - `format?: 'long' | 'short' | 'narrow'` — default `'long'`. `numeric?: 'always' | 'auto'` — default `'auto'` ("yesterday", "now").
1094
+ - `locale?: string`.
1095
+ - `live?: boolean` — default `true`. Ticks every 1 s under a minute, 30 s under an hour, then every minute.
1096
+ - `now?: number` — fixed reference instant (tests/snapshots); disables ticking.
1097
+ - `maxAge?: number` — past this many ms show the absolute date instead.
1098
+ - `absoluteFormat?: Intl.DateTimeFormatOptions` — default `{ dateStyle: 'medium', timeStyle: 'short' }`; used for the tooltip and the `maxAge` fallback.
1099
+ - `title?: boolean | string` — default `true` (absolute time as a plain tooltip). `false` removes it.
1100
+ - `fallback?: ReactNode` — default `'—'`, for an unparsable `value`.
1101
+ - `classes?: Partial<RelativeTimeClasses>` where `RelativeTimeClasses = { root }`.
1102
+
1103
+ ```tsx
1104
+ <RelativeTime value={comment.createdAt} />
1105
+ <RelativeTime value={deploy.finishedAt} format="short" maxAge={7 * 86_400_000} />
1106
+ ```
1107
+
615
1108
  ### Spinner
616
1109
  Import: `import { Spinner } from '@overdoser/react-toolkit'`
617
1110
  Element: a `<span role="status">` (forwards ref). Indeterminate loading spinner; inherits `currentColor`.
@@ -699,7 +1192,7 @@ Off-canvas panel sliding from a screen edge. Portal at `document.body`, focus tr
699
1192
 
700
1193
  Slides in/out with a drawer easing (panel translate + scrim fade); stays mounted through the close transition.
701
1194
  - `aria-label?` / `aria-labelledby?` — if neither, `Drawer.Header` is auto-wired as the label.
702
- - `classes?: Partial<DrawerClasses>` = `{ backdrop, drawer, header, closeButton, body, footer }`.
1195
+ - `classes?: Partial<DrawerClasses>` = `{ backdrop, drawer, header, headerTitle, closeButton, body, footer }`.
703
1196
 
704
1197
  `Drawer.Header` takes `onClose?` (renders an × button). `Drawer.Body`/`Drawer.Footer` take `children`.
705
1198
 
@@ -843,7 +1336,8 @@ Imports: `import { Form, FormField, FormRow } from '@overdoser/react-toolkit'`
843
1336
  `FormField` injects bridges so these inputs work without manual wiring:
844
1337
  - `Input`, `Textarea`, `Select`, `Dropdown` (Mode B), `Checkbox`, `Radio`/`RadioGroup`, `CheckboxGroup`
845
1338
  - For `Select` (multi/searchable) / `Dropdown` (Mode B): bridges `onChange` → `onValueChange`/`onValuesChange`.
846
- - For `Checkbox`: bridges `value` → `checked` when value is boolean.
1339
+ - For `Checkbox`: bridges `value` → `checked` when value is boolean (the boolean is not also written to the `<input>`'s `value`).
1340
+ - `error` is passed to the child as a boolean prop; every supported input accepts it and styles itself (nothing leaks onto the DOM).
847
1341
  - `CheckboxGroup` works directly — its `value: string[]` / `onChange(values)` bind to the field with no extra bridge.
848
1342
 
849
1343
  Note: the inter-field gap is intentionally compact because each field reserves a message line; the overall rhythm stays even without jumping on error.
@@ -880,11 +1374,36 @@ Props:
880
1374
  - `error?: boolean` — default `false`
881
1375
  - `prefix?: ReactNode` — content rendered inside the input wrapper, before the field.
882
1376
  - `suffix?: ReactNode` — same, after the field.
883
- - `classes?: Partial<InputClasses>` where `InputClasses = { root, wrapper, prefix, suffix }`
1377
+ - `revealable?: boolean` — default `false`. With `type="password"`: an eye / eye-off toggle after the field (`aria-pressed`, "Show password" / "Hide password") switches `password` ↔ `text`. Focus stays in the field (no stray blur validation). Ignored for other types.
1378
+ - `revealed?: boolean` + `onRevealedChange?: (revealed: boolean) => void` — controlled reveal state. `revealLabels?: { show: string; hide: string }` overrides the labels.
1379
+ - `clearable?: boolean` — default `false`. A "×" button while the field has a value (controlled or uncontrolled). Clearing fires `onChange` with `target.value === ''` (so controlled inputs and `FormField` update), then `onClear`, and refocuses the field. Hidden when `disabled` / `readOnly`. `clearLabel?: string` — default `'Clear'`. `onClear?: () => void`.
1380
+ - `classes?: Partial<InputClasses>` where `InputClasses = { root, wrapper, prefix, suffix, reveal, clear }`
884
1381
 
885
1382
  Example:
886
1383
  ```tsx
887
1384
  <Input type="email" inputSize="lg" prefix="@" placeholder="username" />
1385
+ <Input type="password" revealable autoComplete="current-password" />
1386
+ <Input clearable value={q} onChange={(e) => setQ(e.target.value)} placeholder="Filter…" />
1387
+ ```
1388
+
1389
+ ### SearchInput
1390
+ Import: `import { SearchInput, formatHotkey } from '@overdoser/react-toolkit'`
1391
+ `Input` preconfigured for search: `type="search"`, leading magnifier, clear button, debounced `onSearch`, optional `loading` spinner and a focus hotkey with a `<Kbd>` hint. The forwarded ref is the `<input>` (`ref.current.focus()`).
1392
+
1393
+ `SearchInputProps` (extends `InputProps` minus `prefix` / `type` / `clearable` — `inputSize`, `error`, `suffix`, `placeholder`, `value`, `defaultValue`, `onChange`, `onClear`, `onKeyDown`… pass through):
1394
+ - `onValueChange?: (value: string) => void` — every keystroke, and `''` on clear / Escape-clear.
1395
+ - `onSearch?: (value: string) => void` — the debounced text after `debounce` ms of quiet; immediately on Enter; `''` on clear. Never on mount, never twice in a row with the same value.
1396
+ - `debounce?: number` — default `300` (`0` = every change).
1397
+ - `loading?: boolean` — default `false`. Spinner in the suffix.
1398
+ - `hotkey?: string | false` — default `false`. Any `useKeyboard` chord (`'/'`, `'mod+k'`) focuses the field; a `<Kbd>` hint shows while empty and unfocused (`showHotkeyHint?: boolean`, default `true`).
1399
+ - `onEscape?: 'clear' | 'blur' | 'none'` — default `'clear'` (clears when there is text, otherwise blurs).
1400
+ - `searchLabel?: string` — default `'Search'`; used as `aria-label` unless you pass `aria-label` / `aria-labelledby`.
1401
+ - `classes?: Partial<SearchInputClasses>` where `SearchInputClasses = InputClasses & { icon, spinner, hint }`.
1402
+ `formatHotkey('mod+k')` → `'⌘K'` on macOS / `'Ctrl K'` elsewhere.
1403
+
1404
+ ```tsx
1405
+ <SearchInput placeholder="Search projects…" hotkey="/" loading={isFetching} onSearch={setQuery} />
1406
+ <SearchInput value={q} onValueChange={setQ} onSearch={runSearch} debounce={200} hotkey="mod+k" inputSize="lg" />
888
1407
  ```
889
1408
 
890
1409
  ### Select
@@ -913,7 +1432,13 @@ Props:
913
1432
  - `onCreate?: (value: string) => void` — Multi-mode only, paired with `allowCreate`. Fires with the new value; consumers typically persist it (e.g. push it back into `options`).
914
1433
  - `createLabel?: (query: string) => ReactNode` — Multi-mode only. Custom render for the create row. Default: `Create "<query>"`.
915
1434
  - `portal?: boolean` — default `true`. Applies to `searchable` + `multiple` modes (native `<select>` is unaffected). The open menu is rendered in a portal at `document.body` with `position: fixed` + `--crk-z-floating` (1060), so it escapes `overflow: hidden` ancestors and sits above `--crk-z-modal` (1050). Means a `<Select>` inside a `<Modal>` works without needing to size the modal. Pass `false` if you need the menu inside the trigger's subtree.
916
- - `classes?: Partial<SelectClasses>` where `SelectClasses = { wrapper, root, arrow, search, menu, item, chip, chipRemove }`
1435
+ - `onSearch?: (query: string) => void` — **remote mode** (searchable + multi): the Select stops filtering `options` locally; you fetch and pass new `options`. Fires with the debounced query, with `''` when the menu opens or the text is cleared, never twice in a row with the same value.
1436
+ - `searchDebounce?: number` — default `250` (`0` = every keystroke). `minSearchLength?: number` — default `0`; shorter queries show `searchPrompt` (default `'Type to search'`) instead of calling `onSearch`.
1437
+ - `loading?: boolean` — default `false`. Spinner in the control and a `loadingMessage` row (default `'Loading…'`) in the menu.
1438
+ - `noResultsMessage?: ReactNode` — default `'No results'`.
1439
+ - `highlightMatches?: boolean` — default `false`. Local filter mode: the matched substring of string labels is wrapped in `<mark>` (semibold, inherits colour).
1440
+ - `selectedLabels?: Record<string, ReactNode>` — fallback label per value when its option isn't in `options` any more (remote results moved on, `allowCreate`). Keeps chips / the trigger labelled.
1441
+ - `classes?: Partial<SelectClasses>` where `SelectClasses = { wrapper, root, arrow, search, menu, item, chip, chipRemove, spinner, match, message }`
917
1442
  - Native props in searchable/multi modes: `name` and `form` go to a hidden native `<select>`, so the value is submitted with native `FormData` (multi submits one entry per value, including `allowCreate` values not yet in `options`). `aria-*`, `data-*`, `title`, `autoFocus`, `tabIndex` go to the visible control; `required` becomes `aria-required` there (no native constraint validation — validate through `FormField` rules). While a searchable Select is open, its search input carries the same `aria-*` props and takes over `id`, so `<label htmlFor>` keeps naming the focused element. `onFocus` / `onBlur` fire when focus enters / leaves the whole widget (trigger, search input and portaled menu count as inside), so blur-based `FormField` validation works.
918
1443
 
919
1444
  Searchable example:
@@ -937,6 +1462,14 @@ Multi example:
937
1462
  />
938
1463
  ```
939
1464
 
1465
+ Async (remote) search — no separate Combobox needed:
1466
+ ```tsx
1467
+ <Select searchable options={results} loading={isFetching} onSearch={fetchUsers}
1468
+ value={userId} onValueChange={setUserId} selectedLabels={{ [userId]: userName }} placeholder="Search people…" />
1469
+ <Select multiple closeOnSelect={false} options={results} loading={isFetching} onSearch={fetchTags}
1470
+ minSearchLength={2} value={tagIds} onValuesChange={setTagIds} selectedLabels={tagLabelsById} />
1471
+ ```
1472
+
940
1473
  ### Checkbox
941
1474
  Import: `import { Checkbox } from '@overdoser/react-toolkit'`
942
1475
  Element: `<input type="checkbox">` wrapped in a `<label>` (forwards ref to the input).
@@ -945,6 +1478,7 @@ Props (extends native input props):
945
1478
  - `label?: ReactNode`
946
1479
  - `variant?: 'checkbox' | 'switch'` — default `'checkbox'`. `'switch'` renders a sliding toggle; the underlying `<input type="checkbox">` (a11y + form behavior) is identical.
947
1480
  - `indeterminate?: boolean` — default `false`. Sets the DOM `indeterminate` property; visually distinct. Ignored when `variant="switch"`.
1481
+ - `error?: boolean` — default `false`. Error styling (danger border). Set automatically by `FormField` when the field is invalid.
948
1482
  - `classes?: Partial<CheckboxClasses>` where `CheckboxClasses = { root, input, label }`
949
1483
 
950
1484
  Example:
@@ -953,6 +1487,17 @@ Example:
953
1487
  <Checkbox variant="switch" label="Notifications" defaultChecked />
954
1488
  ```
955
1489
 
1490
+ ### Switch
1491
+ Import: `import { Switch } from '@overdoser/react-toolkit'`
1492
+ Element: `<input type="checkbox">` inside a `<label>` (forwards ref to the input). **The same control as `<Checkbox variant="switch">`** — a sliding toggle with identical a11y and form behaviour. Exists so "toggle switch" is findable; do not hand-roll one.
1493
+
1494
+ `SwitchProps = Omit<CheckboxProps, 'variant' | 'indeterminate'>`: `label?`, `error?`, `classes?` (`SwitchClasses = { root, input, label }`), plus native input props (`checked`, `defaultChecked`, `onChange`, `disabled`, `name`…). Binds inside `FormField` for a boolean field exactly like `Checkbox`.
1495
+
1496
+ ```tsx
1497
+ <Switch label="Notifications" checked={on} onChange={(e) => setOn(e.target.checked)} />
1498
+ <FormField name="enabled" label="Enabled"><Switch /></FormField>
1499
+ ```
1500
+
956
1501
  ### CheckboxGroup
957
1502
  Import: `import { CheckboxGroup } from '@overdoser/react-toolkit'`
958
1503
  Element: a `[role="group"]` `<div>` (forwards ref to it). Multi-value selection from a fixed option set.
@@ -992,10 +1537,13 @@ Import: `import { Radio, RadioGroup } from '@overdoser/react-toolkit'`
992
1537
  - `id?: string`
993
1538
  - `aria-label?` / `aria-labelledby?`
994
1539
  - `required?: boolean`
1540
+ - `error?: boolean` — default `false`. Error styling on every `Radio` inside. Set automatically by `FormField`.
1541
+ - Forwards ref to the `[role="radiogroup"]` `<div>`.
995
1542
 
996
1543
  `Radio` props (extends native input props minus `type`):
997
1544
  - `value: string` — required.
998
1545
  - `label?: ReactNode`
1546
+ - `error?: boolean` — default `false`. Error styling (danger border).
999
1547
  - `classes?: Partial<RadioClasses>` where `RadioClasses = { root, input, label }`
1000
1548
 
1001
1549
  Inside a `RadioGroup`, individual `Radio` components do NOT need their own `name`/`checked`/`onChange` — the group provides them via context.
@@ -1559,14 +2107,60 @@ useFocusTrap(dialogRef, isOpen);
1559
2107
 
1560
2108
  ### useKeyboard
1561
2109
  Import: `import { useKeyboard } from '@overdoser/react-toolkit'`
1562
- Signature: `useKeyboard(handlers: Record<string, (e: KeyboardEvent) => void>, active?: boolean): void`
2110
+ Signature: `useKeyboard(handlers: Record<string, (e: KeyboardEvent) => void>, options?: boolean | UseKeyboardOptions): void`
2111
+
2112
+ Global keydown handlers keyed by key name **or chord**: `'Escape'`, `'Enter'`, `'ArrowDown'`, `'k'`, `'?'`, `'mod+k'`, `'ctrl+shift+z'`, `'alt+ArrowUp'`. `mod` = ⌘ on macOS, Ctrl elsewhere; aliases `esc`, `cmd`, `space`, `up/down/left/right` accepted. Handlers are read through a ref — inline objects don't re-subscribe.
2113
+ `UseKeyboardOptions` (a bare `boolean` = `{ active }`):
2114
+ - `active?: boolean` — default `true`.
2115
+ - `ignoreEditable?: boolean` — default `true`. Plain printable keys (`'k'`, `'/'`) are skipped while typing in an input/textarea/select/contenteditable; named keys and modifier chords still fire there.
2116
+ - `preventDefault?: boolean` — default: only for chords with a modifier (`mod+k` won't reach the browser; a bare `ArrowDown` still scrolls).
2117
+ - `target?: RefObject<HTMLElement>` — listen on an element instead of `document`.
2118
+
2119
+ ```tsx
2120
+ useKeyboard({ Escape: close, Enter: confirm }, isOpen);
2121
+ useKeyboard({ 'mod+k': openPalette, '/': focusSearch, 'mod+shift+z': redo });
2122
+ ```
2123
+
2124
+ ### usePersistedState
2125
+ Import: `import { usePersistedState } from '@overdoser/react-toolkit'`
2126
+ Signature: `usePersistedState<T>(key: string, initialValue: T | (() => T), options?): [value, setValue, remove]`
1563
2127
 
1564
- Binds global keydown listeners keyed by `KeyboardEvent.key`. `active` defaults to `true`.
2128
+ `useState` persisted to `localStorage` (`options.storage: 'session'` for sessionStorage). SSR-safe (server snapshot = initial), private-mode/quota safe (falls back to memory), two hooks on one key stay in sync in-tab and across tabs (`options.sync`, default `true`). `options.serialize` / `deserialize` default to JSON. Built on `useSyncExternalStore`. Use for theme, sidebar collapsed, column visibility, drafts.
1565
2129
 
1566
2130
  ```tsx
1567
- useKeyboard({ Escape: () => close(), Enter: () => confirm() }, isOpen);
2131
+ const [collapsed, setCollapsed] = usePersistedState('sidebar:collapsed', false);
2132
+ const [draft, setDraft, clearDraft] = usePersistedState('draft', '', { storage: 'session' });
1568
2133
  ```
1569
2134
 
2135
+ ### useDebouncedValue
2136
+ Signature: `useDebouncedValue<T>(value: T, delay = 300): T` — returns `value` once it has been stable for `delay` ms (first render returns it immediately). Pair with a search input.
2137
+
2138
+ ### useMediaQuery
2139
+ Signature: `useMediaQuery(query: string, serverValue = false): boolean` — subscribes to `matchMedia`; SSR-safe. `useMediaQuery('(max-width: 768px)')`, `useMediaQuery('(prefers-color-scheme: dark)')`.
2140
+
2141
+ ### useElementSize
2142
+ Signature: `useElementSize(ref, box = 'content-box'): { width, height }` — `ResizeObserver`-backed; `{ 0, 0 }` until measured; stable object while unchanged.
2143
+
2144
+ ### useTheme
2145
+ Signature: `useTheme({ storageKey?: 'crk-theme', attribute?: 'data-theme', defaultTheme?: 'system' }?): { theme: 'light' | 'dark' | 'system', resolved: 'light' | 'dark', setTheme, toggle }` — persists the choice, sets `data-theme` on `<html>` (removed for `system`), follows `prefers-color-scheme` for `resolved`; all instances stay in sync; SSR-safe. Pair with `THEME_INIT_SCRIPT` in `<head>` to avoid a flash.
2146
+
2147
+ ### useResizable
2148
+ Signature: `useResizable({ size?, defaultSize?, min?, max?: number | (() => number), axis?: 'x' | 'y', invert?, step?, onResize?, onResizeStart?, onResizeEnd?, disabled? }): { size, setSize, isResizing, reset, handleProps }` — the drag/keyboard engine behind `SplitPane`. Spread `handleProps` (pointer + key handlers, `role="separator"`, aria values, `tabIndex`) on your own handle element; `invert` for a right/bottom-anchored pane; double-click resets.
2149
+
2150
+ ### useNow
2151
+ Signature: `useNow(interval = 1000, active = true): number` — current epoch ms, re-rendering every `interval`. All subscribers with the same interval share one timer. Backs `RelativeTime`.
2152
+
2153
+ ## Utils
2154
+
2155
+ ### formatBytes
2156
+ `formatBytes(bytes: number, { decimals = 1, base = 1024, iec = false, locale }?): string` — `formatBytes(1536)` → `"1.5 KB"`, `formatBytes(2048, { iec: true })` → `"2.0 KiB"`, whole bytes have no decimals (`"512 B"`).
2157
+
2158
+ ### THEME_INIT_SCRIPT / getThemeInitScript
2159
+ `THEME_INIT_SCRIPT: string` — inline script for `<head>` that applies the stored theme before first paint. `getThemeInitScript({ storageKey?, attribute? })` builds one for custom keys.
2160
+
2161
+ ### timeAgo
2162
+ `timeAgo(value: Date | number | string, { now, locale, format, numeric, maxAge }?): string | null` — `"3 minutes ago"`, `"in 2 hours"`, `"yesterday"` via `Intl.RelativeTimeFormat`; `null` past `maxAge` or for an unparsable value. `RelativeTime` is the live component version.
2163
+
1570
2164
  ## Conventions worth knowing
1571
2165
 
1572
2166
  1. **Inputs use `inputSize`** for the toolkit size scale. The native `size` HTML attribute is independent.