nish-ui 0.0.0-stage → 1.4.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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +561 -2
  3. package/dist/base.css +1612 -0
  4. package/dist/chart.d.ts +44 -0
  5. package/dist/chart.js +406 -0
  6. package/dist/chart.js.map +1 -0
  7. package/dist/files.json +11 -0
  8. package/dist/fonts/inter-latin-ext-wght-normal.34b9c504.woff2 +0 -0
  9. package/dist/fonts/inter-latin-wght-normal.3100e775.woff2 +0 -0
  10. package/dist/fonts.css +22 -0
  11. package/dist/format.d.ts +59 -0
  12. package/dist/format.js +202 -0
  13. package/dist/format.js.map +1 -0
  14. package/dist/inbox-client.d.ts +226 -0
  15. package/dist/inbox-client.js +318 -0
  16. package/dist/inbox-client.js.map +1 -0
  17. package/dist/index.d.ts +3302 -0
  18. package/dist/index.js +9912 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/nish-components.css +2242 -0
  21. package/dist/nish.css +2134 -0
  22. package/dist/node/eslint.d.ts +70 -0
  23. package/dist/node/eslint.js +441 -0
  24. package/dist/node/th-check.d.ts +8 -0
  25. package/dist/node/th-check.js +411 -0
  26. package/dist/node/vite.d.ts +30 -0
  27. package/dist/node/vite.js +28 -0
  28. package/dist/server/hono.d.ts +70 -0
  29. package/dist/server/hono.js +276 -0
  30. package/dist/server/hono.js.map +1 -0
  31. package/dist/server/index.d.ts +192 -0
  32. package/dist/server/index.js +797 -0
  33. package/dist/server/index.js.map +1 -0
  34. package/dist/spa-EPM1E0Va.d.ts +239 -0
  35. package/dist/split-layout.d.ts +59 -0
  36. package/dist/split-layout.js +420 -0
  37. package/dist/split-layout.js.map +1 -0
  38. package/dist/system-canvas.d.ts +168 -0
  39. package/dist/system-canvas.js +2204 -0
  40. package/dist/system-canvas.js.map +1 -0
  41. package/dist/tailwind.css +120 -0
  42. package/dist/theme-init.js +52 -0
  43. package/dist/theme.d.ts +176 -0
  44. package/dist/theme.global.js +984 -0
  45. package/dist/theme.global.js.map +1 -0
  46. package/dist/theme.js +946 -0
  47. package/dist/theme.js.map +1 -0
  48. package/dist/tokens.css +496 -0
  49. package/dist/tokens.d.ts +17 -0
  50. package/dist/tokens.js +410 -0
  51. package/package.json +147 -4
  52. package/tsconfig/base.json +20 -0
  53. package/tsconfig/node.json +10 -0
  54. package/tsconfig/react.json +10 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nishant Arora
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,562 @@
1
- # Temporary Holding Version
1
+ # @nish/ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Design tokens, seven themes, theme switching that can follow one choice across subdomains, and
4
+ the React components behind every `*.nish.software` app. Tailwind 4 first, with plain CSS and
5
+ static HTML supported too.
6
+
7
+ Docs, live components in every theme, and the contrast matrix: **https://design.nish.software**
8
+
9
+ MIT licensed. Releases and how they reach the apps: [docs/RELEASING.md](docs/RELEASING.md).
10
+ Every change: [CHANGELOG.md](CHANGELOG.md).
11
+
12
+ ## Install
13
+
14
+ From npm:
15
+
16
+ ```bash
17
+ npm install nish-ui
18
+ pnpm add nish-ui
19
+ ```
20
+
21
+ These docs write the package as `@nish/ui`, its name in the nish.software apps. Either read
22
+ `nish-ui` wherever they say `@nish/ui` (`nish-ui/tailwind.css`, `nish-ui/theme`, ...), or install
23
+ it under that name with an npm alias and every import works as written:
24
+
25
+ ```bash
26
+ npm install @nish/ui@npm:nish-ui
27
+ ```
28
+
29
+ Straight from a git tag, whose commit includes the built `dist/`, so there is no build step:
30
+
31
+ ```json
32
+ "@nish/ui": "https://codeload.github.com/nishant/ui/tar.gz/refs/tags/v1.2.0"
33
+ ```
34
+
35
+ The codeload tarball needs only HTTPS. `github:nishant/ui#v1.2.0` works as well, but it clones
36
+ over SSH when the machine has a key, and fails where GitHub does not accept that key (CI
37
+ runners, servers).
38
+
39
+ React and react-dom are optional peers (React 19 or later). Static sites and tools that
40
+ only use the CSS and `@nish/ui/theme` do not get React installed. The `@nish/ui/server`,
41
+ `@nish/ui/server/hono` and `@nish/ui/inbox-client` entries are the nish.software apps' login
42
+ and inbox kit; other projects can ignore them.
43
+
44
+ ## Quick start: React + Tailwind 4
45
+
46
+ ```css
47
+ /* src/index.css */
48
+ @import 'tailwindcss';
49
+ @import '@nish/ui/tailwind.css';
50
+ ```
51
+
52
+ The `nishThemeInit()` plugin from `@nish/ui/vite` inlines `theme-init.js` at the top of `<head>`, so
53
+ the saved theme is on `<html>` before the first paint. Options: `position: 'after-charset'`,
54
+ `prelude`, `legacyKey` (see [Vite plugin and lint](https://design.nish.software/#/components/vite-plugin)).
55
+
56
+ ```ts
57
+ // vite.config.ts
58
+ import { nishThemeInit } from '@nish/ui/vite';
59
+ // plugins: [nishThemeInit(), react(), tailwindcss()]
60
+ ```
61
+
62
+ ```tsx
63
+ import { initTheme, ThemeToggle, Toaster, Button, toast } from '@nish/ui';
64
+
65
+ initTheme(); // once, before render
66
+
67
+ <ThemeToggle presets /> {/* in the header */}
68
+ <Toaster /> {/* once, at the root */}
69
+ <Button variant="primary" onClick={() => toast.success('Saved')}>Save</Button>
70
+ ```
71
+
72
+ ## Lint
73
+
74
+ Two guards stop a made-up theme class (a `bg-th-` name that is not a role compiles to nothing, so the
75
+ element silently loses its background) from shipping.
76
+
77
+ ```js
78
+ // eslint.config.js: after tseslint.configs.recommended; it ships rules only, no parser
79
+ import tseslint from 'typescript-eslint';
80
+ import nish from '@nish/ui/eslint';
81
+
82
+ export default [...tseslint.configs.recommended, ...nish.configs.react]; // servers: nish.configs.node
83
+ ```
84
+
85
+ The preset is the plugin `nish` with six rules, all errors: `no-unknown-th-class`, `no-raw-palette`,
86
+ `no-white-black`, `no-legacy-th-alias`, `no-hand-mixed-tint` and `no-arbitrary-text-size`. It has its
87
+ own rules rather than `no-restricted-syntax`, so it never replaces an app's own options.
88
+
89
+ `nish-th-check [dir|file ...]` (default `src`) does the unknown-class check alone, for CSS and HTML too,
90
+ and exits 1 with file:line for each hit. Add `"th-check": "nish-th-check src"` to `package.json` and run it
91
+ in `check`. This repo runs it over `src site demo` in `npm run check`.
92
+
93
+ ## TypeScript presets
94
+
95
+ ```json
96
+ // tsconfig.json of a Vite + React app; servers and scripts extend node.json
97
+ { "extends": "@nish/ui/tsconfig/react.json", "include": ["src"] }
98
+ ```
99
+
100
+ `base.json` is strict, ES2023, Bundler resolution, isolatedModules and noEmit. `react.json` adds the DOM libs,
101
+ `react-jsx` and `vite/client` types. `node.json` switches to NodeNext with `node` types.
102
+
103
+ ## Icons
104
+
105
+ Apps use `lucide-react` (^1): per-icon tree-shaking, a large maintained set, MIT, and trading, startpage
106
+ and nishboard already use it. `@nish/ui` never depends on an icon package. Its components inline the few
107
+ icons they need, drawn on lucide's 24px grid with a 2px stroke so they match, and it exports five of them
108
+ (`CheckIcon`, `ClockIcon`, `MoreIcon`, `BellIcon`, `SettingsIcon`). Sizes: 16px inline with text, 20px in
109
+ buttons and IconButtons, 20 to 24px in navigation (`NavItem.icon`). Details: [Icons](https://design.nish.software/#/icons).
110
+
111
+ ## Quick start: static HTML
112
+
113
+ Copy the files listed in `dist/files.json` from a tag (`nish.css`, `nish-components.css`,
114
+ `theme-init.js`, `theme.js`, `theme.global.js` and `fonts/*`). hosting does this with
115
+ `scripts/sync-ui.mjs`. Then:
116
+
117
+ ```html
118
+ <head>
119
+ <script src="nish/theme-init.js"></script>
120
+ <link rel="stylesheet" href="nish/nish.css">
121
+ <!-- optional: .nish-btn, .nish-card, .nish-badge and the other component classes -->
122
+ <link rel="stylesheet" href="nish/nish-components.css">
123
+ </head>
124
+ <body>
125
+ <button id="theme" type="button" class="nish-theme-btn"></button>
126
+ <script type="module">
127
+ import { initTheme, mountThemeToggle } from './nish/theme.js';
128
+ initTheme();
129
+ // Fills the button with the System, Light and Dark icons, keeps its label right, cycles on click.
130
+ mountThemeToggle(document.querySelector('#theme'));
131
+ </script>
132
+ </body>
133
+ ```
134
+
135
+ Pages that cannot use modules load the classic-script build instead. It defines
136
+ `window.nishTheme` with `initTheme`, `setThemeChoice`, `cycleTheme`, `onThemeChange`,
137
+ `readToken`, `registerThemes`, `getThemeChoice` and `mountThemeToggle`:
138
+
139
+ ```html
140
+ <script src="nish/theme.global.js"></script>
141
+ <script>
142
+ nishTheme.initTheme();
143
+ nishTheme.mountThemeToggle(document.querySelector('#theme'));
144
+ </script>
145
+ ```
146
+
147
+ Style with the variables: `background: var(--nish-surface); color: var(--nish-hi2);`.
148
+ Font files have content-hashed names (`inter-latin-wght-normal.<hash>.woff2`), so the
149
+ folder they live in can be served with a one-year immutable cache.
150
+
151
+ ## Quick start: Electron
152
+
153
+ The renderer is a React + Tailwind app: same install, same CSS import. Two differences:
154
+
155
+ - Inline `theme-init.js` (`nishThemeInit()` above). The packaged app loads from `file://`,
156
+ where only an inline, render-blocking script is guaranteed to run before the first paint.
157
+ - There is no shared domain, so the choice lives in `localStorage` only. Keep the native
158
+ window chrome in step from the renderer:
159
+
160
+ ```ts
161
+ import { initTheme, onThemeChange, schemeOf } from '@nish/ui';
162
+ initTheme();
163
+ onThemeChange((_choice, theme) => window.api.setNativeTheme(schemeOf(theme)));
164
+ // main process: ipcMain.on('theme', (_e, s) => (nativeTheme.themeSource = s));
165
+ ```
166
+
167
+ ## Themes
168
+
169
+ `dark` (the default), `light`, and the presets `slate`, `terminal`, `mocha`, `ocean` and
170
+ `contrast` (high contrast). Each preset declares whether it is dark or light, so a page
171
+ limited to light and dark (`<html data-nish-themes="dark light">`) shows the one it is
172
+ based on.
173
+
174
+ The choice (`system` or a theme name) is shared across subdomains:
175
+
176
+ - `setThemeChoice()` writes a `nish-theme` cookie on `.nish.software`
177
+ (`Path=/; Max-Age=31536000; SameSite=Lax; Secure`) and the same value to `localStorage`.
178
+ Another site shares it across its own subdomains with `<html data-nish-domain="example.com">`
179
+ (it applies only on that domain and its subdomains). Without the attribute, hosts outside
180
+ nish.software keep the choice in `localStorage` only.
181
+ - `theme-init.js` reads the cookie first, then `localStorage` (the only store on localhost
182
+ and in Electron), then follows the OS.
183
+ - `theme.ts` re-applies the choice when another tab saves one, when the OS scheme flips
184
+ (for `system`), and when a tab comes back into view after another subdomain changed the
185
+ cookie.
186
+
187
+ So picking Mocha on jobs.nish.software opens trading.nish.software in Mocha too.
188
+
189
+ A theme can also be scoped to part of a page: `<div data-theme="light" data-scheme="light">`
190
+ gets that theme's colors, tints and shadows for its subtree. The docs site's all-themes
191
+ views work this way. Tailwind's `dark:` variant matches when any ancestor has
192
+ `data-scheme="dark"`, so inside a light container on a dark page it still applies; use
193
+ roles instead of `dark:` in scoped content.
194
+
195
+ ## Color roles
196
+
197
+ Pick colors by role, never by hue. Each role is a CSS variable and a Tailwind color
198
+ (`bg-`, `text-`, `border-`, `ring-`, `fill-`, `stroke-` all work, as do opacity
199
+ modifiers like `bg-th-surface/50`). Never use raw palette classes such as `neutral-800`:
200
+ they do not change with the theme.
201
+
202
+ | Role | Purpose | Tailwind | CSS variable |
203
+ |---|---|---|---|
204
+ | bg | Page background | `bg-th-bg` | `--nish-bg` |
205
+ | surface | Cards, panels, table bodies | `bg-th-surface` | `--nish-surface` |
206
+ | elevated | Popovers, hovered rows, inputs, raised things inside cards | `bg-th-elevated` | `--nish-elevated` |
207
+ | overlay | Deepest layer: chips inside raised things, skeleton sheen | `bg-th-overlay` | `--nish-overlay` |
208
+ | line | Borders and dividers | `border-th-line` | `--nish-line` |
209
+ | line-strong | Input borders, outlines that are not the accent | `border-th-line-strong` | `--nish-line-strong` |
210
+ | hi | Primary text | `text-th-hi` | `--nish-hi` |
211
+ | hi2 | Secondary text | `text-th-hi2` | `--nish-hi2` |
212
+ | hi3 | Tertiary text, labels | `text-th-hi3` | `--nish-hi3` |
213
+ | ghost | Placeholders, disabled text, decorative icons (not body text) | `text-th-ghost` | `--nish-ghost` |
214
+ | accent | Links, primary buttons, active nav, focus ring | `text-th-accent`, `bg-th-accent` | `--nish-accent` |
215
+ | accent2 | Second accent for paired highlights | `text-th-accent2` | `--nish-accent2` |
216
+ | ok / loss / warn / info | Status text: success, errors, warnings, notices | `text-th-ok` | `--nish-ok` |
217
+ | *-soft | A role at 14% for badges, banners, selected rows (accent, ok, loss, warn, info) | `bg-th-ok-soft` | `--nish-ok-soft` |
218
+ | *-fill | Status colors for bars, meters, dots and chart lines (brighter than the text versions in light themes) | `bg-th-ok-fill` | `--nish-ok-fill` |
219
+ | on-accent | Text and icons on an accent fill | `text-th-on-accent` | `--nish-on-accent` |
220
+ | on-accent2 | Text and icons on an accent2 fill | `text-th-on-accent2` | `--nish-on-accent2` |
221
+ | on-ok / on-loss / on-warn / on-info | Text and icons on the matching `-fill` (on-loss also on `loss`, for danger buttons) | `text-th-on-ok` | `--nish-on-ok` |
222
+ | scrim | Modal and drawer backdrop tone | `bg-th-scrim/60` | `--nish-scrim` |
223
+ | invert-bg / invert-text | Inverted pill: a today marker, an active segment | `bg-th-invert-bg` | `--nish-invert-bg` |
224
+ | chart-1 … chart-8 | Categorical chart series; neighbors never share a hue family | `stroke-th-chart-1` | `--nish-chart-1` |
225
+ | emerald, indigo, amber, lime, rose, sky, violet, teal | Hues for tags and tile accents, when a color has no meaning | `text-th-rose` | `--nish-rose` |
226
+
227
+ Aliases kept for older apps: `th-gain` (ok), `th-danger` (loss), `th-2` (hi2), `th-3`
228
+ (hi3), `th-bar` (surface), `th-focus`.
229
+
230
+ Every value per theme, live, is on the [Color page](https://design.nish.software/#/color).
231
+
232
+ ## Layout contract
233
+
234
+ Bars publish their height to CSS variables on `<html>` (a ResizeObserver; the variable is removed when the bar unmounts or is hidden). Everything else reads the variables, so no React context is needed, and static pages use the same contract through `mountHeightVar`.
235
+
236
+ | Variable | Written by | Value | Read by |
237
+ |---|---|---|---|
238
+ | `--nish-header-h` | AppHeader when `sticky` (default) | measured height in px | PageHeader sticky top, StickyBar default top, SectionNav top, `.nish-scroll-target` scroll margin |
239
+ | `--nish-bottom-nav-h` | BottomNav while visible (below `hideFrom`) | measured height, safe area included | `--nish-bottom-inset`, StickyActionBar, MoreSheet |
240
+ | `--nish-bottom-bar-h` | StickyActionBar while open | measured height | `--nish-bottom-inset` |
241
+ | `--nish-bottom-inset` | base.css only | `calc(var(--nish-bottom-nav-h, 0px) + var(--nish-bottom-bar-h, 0px))` | Toaster, PageContainer bottom padding, `.nish-pad-bottom-inset` |
242
+ | `--nish-sticky-extra` | SectionNav and StickyBar when sticky | measured height | `.nish-scroll-target` scroll margin |
243
+ | `--nish-page-gutter` | base.css (1rem, 1.5rem from 640px) | side padding | AppHeader, PageHeader, PageContainer |
244
+
245
+ `html[data-nish-layer-open]` is set while any Modal, Drawer or ConfirmDialog is open; Toaster uses it to move to the top on phones. A custom bar publishes its height with `useHeightVar(ref, '--nish-bottom-bar-h')`; a sticky element can use `useStuck(ref)` for a stuck shadow, and a scroller `useScrollEdges(ref)` with `.nish-scroll-fade` for edge fades.
246
+
247
+ ## Phone chrome
248
+
249
+ A header on top, a tab bar at the bottom on phones, a rail on wide screens and a "More" sheet for the rest. Toaster needs no `offset`: it sits above the tab bar through `--nish-bottom-inset`.
250
+
251
+ ```tsx
252
+ import { AppHeader, BottomNav, MoreSheet, NavRail, PageContainer, Toaster } from '@nish/ui';
253
+
254
+ const [more, setMore] = useState(false);
255
+
256
+ <AppHeader name="Trackers" hubHref="https://nish.software" actions={<Search />} />
257
+ <NavRail items={primary} /> {/* md and up */}
258
+ <PageContainer>{children}</PageContainer> {/* pads for the bottom inset */}
259
+ <BottomNav {/* below md */}
260
+ items={primary}
261
+ more={{ active: false, expanded: more, onToggle: () => setMore((v) => !v) }}
262
+ />
263
+ <MoreSheet open={more} onClose={() => setMore(false)} items={secondary} />
264
+ <Toaster /> {/* no offset */}
265
+ ```
266
+
267
+ `items` are `NavItem`s (`key`, `label`, `icon`, `href` or `onSelect`, `active`, `badge`). Pass `renderLink` to use your router's Link.
268
+
269
+ Use this viewport meta in `<head>`:
270
+
271
+ ```html
272
+ <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content">
273
+ ```
274
+
275
+ Do not ship a static `<meta name="theme-color">`: `theme-init.js` creates and updates its own from the active theme, and removes any static one at load.
276
+
277
+ ## Formatting: `@nish/ui/format`
278
+
279
+ A React-free entry for money, percentages, numbers, bytes, durations and dates: `money`, `signedMoney`, `pct`, `num`, `signed`, `bytes`, `duration`, `ago`, `date`, `time`, `dateTime`, `dateRange`. Each returns an en dash for null, undefined, NaN and invalid dates, and works in static pages and on servers. It is not re-exported from `@nish/ui`.
280
+
281
+ ```ts
282
+ import { money, pct, ago } from '@nish/ui/format';
283
+
284
+ money(1234.5); // "$1,234.50"
285
+ pct(0.0312, { fromRatio: true }); // "3.1%"
286
+ ago(Date.now() - 3 * 60_000); // "3m"
287
+ ```
288
+
289
+ ## Components
290
+
291
+ | Component | What it is | Docs |
292
+ |---|---|---|
293
+ | `Button`, `buttonClass()` | The standard action: primary, secondary, ghost, danger, soft, subtle and link; xs to lg; loading; `buttonClass()` for links | [Button](https://design.nish.software/#/components/button) |
294
+ | `IconButton`, `iconButtonClass()` | Icon-only button, 2xs/xs/sm/md, ghost/subtle/soft, danger tone; the required label is its accessible name and title | [IconButton](https://design.nish.software/#/components/icon-button) |
295
+ | `Card`, `cardClass()` | Surface panel: padding none/sm/md/lg, `as`, inset variant, optional header via title/description/action | [Card](https://design.nish.software/#/components/card) |
296
+ | `CardHeader` | Card header row: title, description, icon, action slot, divided | [CardHeader](https://design.nish.software/#/components/card-header) |
297
+ | `Badge`, `badgeClass()` | Status pill: 6 tones plus on-accent, 8 hues, xs/sm, pill or tag, optional dot | [Badge](https://design.nish.software/#/components/badge) |
298
+ | `Input`, `fieldClass()` | Text field: xs/sm/md, leading/trailing slots, invalid; 16px text and 44px on touch | [Input](https://design.nish.software/#/components/input) |
299
+ | `Textarea` | Multi-line text with the field look; sm/md, `autoGrow` | [Textarea](https://design.nish.software/#/components/textarea) |
300
+ | `Checkbox` | A checkbox with its label and hint, indeterminate, trailing slot; the whole row is the tap target | [Checkbox](https://design.nish.software/#/components/checkbox) |
301
+ | `Field` | Label, one control and its hint or error, wired for screen readers | [Field](https://design.nish.software/#/components/field) |
302
+ | `FieldGroup` | Field for a group of controls: a fieldset and legend, hint and error tied to the group | [FieldGroup](https://design.nish.software/#/components/field-group) |
303
+ | `Switch` | On/off setting that applies at once (`role="switch"`), with label and description | [Switch](https://design.nish.software/#/components/switch) |
304
+ | `SearchInput` | Search field with icon, Clear button and Escape to clear | [SearchInput](https://design.nish.software/#/components/search-input) |
305
+ | `Select` | Native select with the field look, xs/sm/md; keeps the platform picker on phones | [Select](https://design.nish.software/#/components/select) |
306
+ | `Label` | Small uppercase label for fields and card sections | [Label](https://design.nish.software/#/components/label) |
307
+ | `Skeleton`, `SkeletonLines` | Shimmer placeholders: one sized block, or a ready-made card body | [Skeleton](https://design.nish.software/#/components/skeleton) |
308
+ | `SkeletonRows` | A loading column of full-width rounded rows for lists and card pages | [SkeletonRows](https://design.nish.software/#/components/skeleton-rows) |
309
+ | `Spinner` | Loader in the current text color; with a label it is `role="status"` | [Spinner](https://design.nish.software/#/components/spinner) |
310
+ | `EmptyState` | What an empty list or widget shows: title, one line of why, an action | [EmptyState](https://design.nish.software/#/components/empty-state) |
311
+ | `ErrorState` | A failed load, announced to screen readers, with an optional Retry | [ErrorState](https://design.nish.software/#/components/error-state) |
312
+ | `Toaster`, `toast()` | Toast stack; `toast.success/error/warn/info` from anywhere, with body, action, duration and slot id; `offset` and `offsetUntil` clear a bottom tab bar | [Toast](https://design.nish.software/#/components/toast) |
313
+ | `Callout` | Inline tinted notice: tone, icon, title, action, dismiss, box or bar | [Callout](https://design.nish.software/#/components/callout) |
314
+ | `StatusDot` | Round status mark on the `-fill` roles, optional pulse and halo | [StatusDot](https://design.nish.software/#/components/status-dot) |
315
+ | `Stat`, `StatGrid`, `signTone()` | Labelled numbers in a `<dl>` grid; tone from a signed number | [Stat](https://design.nish.software/#/components/stat) |
316
+ | `Meter`, `toneFor()` | Thin meter or progress bar with threshold tones, or a neutral fill | [Meter](https://design.nish.software/#/components/meter) |
317
+ | `FlowSteps` | Animated plan: numbered steps joined by connectors that fill, a rippling active step, check draw, vertical or horizontal | [FlowSteps](https://design.nish.software/#/components/flow-steps) |
318
+ | `StepBar` | Compact segmented progress bar with a pulsing current segment | [StepBar](https://design.nish.software/#/components/step-bar) |
319
+ | `AgentNode` | Card for one agent or task: state icon, model badge, live activity line, running comet border | [AgentNode](https://design.nish.software/#/components/agent-node) |
320
+ | `WorkflowBoard` | Phases as columns (stacked when narrow) holding AgentNodes, with glow, progress and flowing connectors | [WorkflowBoard](https://design.nish.software/#/components/workflow-board) |
321
+ | `ActivityFeed` | Timeline of short updates, newest first; new rows open, fade in and flash | [ActivityFeed](https://design.nish.software/#/components/activity-feed) |
322
+ | `TickerText` | One line of text that slides when it changes | [TickerText](https://design.nish.software/#/components/ticker-text) |
323
+ | `AnimatedList`, `usePrefersReducedMotion()` | List with enter, exit and FLIP move animations; hook for the reduced-motion preference | [AnimatedList](https://design.nish.software/#/components/animated-list) |
324
+ | `SystemCanvas`, `layoutSystem()`, `pickLayout()`, `routeEdges()` | Pannable, zoomable graph-paper canvas of grouped nodes and right-angled edges, laid out in bands or columns (`layout="auto"` picks); edge kinds with a legend, hover focus, follow mode and a minimap. Also importable on its own from `@nish/ui/system-canvas` | [SystemCanvas](https://design.nish.software/#/components/system-canvas) |
325
+ | `Sparkline` | Dependency-free SVG trend line | [Sparkline](https://design.nish.software/#/components/sparkline) |
326
+ | `Disclosure` | `<details>` show-more, plain or card | [Disclosure](https://design.nish.software/#/components/disclosure) |
327
+ | `Kbd` | Keyboard key | [Kbd](https://design.nish.software/#/components/kbd) |
328
+ | `CopyButton`, `copyText()` | Copy to clipboard with a "Copied" state and a live announcement | [CopyButton](https://design.nish.software/#/components/copy-button) |
329
+ | `PageHeader` | Page title block with back link, eyebrow, description and actions | [PageHeader](https://design.nish.software/#/components/page-header) |
330
+ | `AppHeader` | Shared app header: hub pill, wordmark (optionally a home link, icon only on phones), actions, theme toggle, named nav row | [AppHeader](https://design.nish.software/#/components/app-header) |
331
+ | `SectionHeader` | A section's heading row inside a page, with meta and an action | [SectionHeader](https://design.nish.software/#/components/section-header) |
332
+ | `KeyValueList` | Label and value rows with dividers, as a list or a `<dl>` | [KeyValueList](https://design.nish.software/#/components/key-value-list) |
333
+ | `ChartLegend` | The key for multi-series charts: a color mark and a name per series | [ChartLegend](https://design.nish.software/#/components/chart-legend) |
334
+ | `TableWrap`, `Table`, `Th`, `Td`, `Tr`, `tableClass` | Table primitives (sticky header, sort, tone edge) and class recipes for TanStack | [Table](https://design.nish.software/#/components/table) |
335
+ | `Modal` | Dialog; bottom sheet under 640px; sizes md to full, top placement, custom header; Escape, focus trap, focus return, html and body scroll lock | [Modal](https://design.nish.software/#/components/modal) |
336
+ | `Drawer` | Side or bottom panel with the Modal's focus trap, Escape and scroll lock | [Drawer](https://design.nish.software/#/components/drawer) |
337
+ | `ConfirmDialog` | Yes-or-no question before an action, in place of `window.confirm` | [ConfirmDialog](https://design.nish.software/#/components/confirm-dialog) |
338
+ | `Tooltip` | Hover and focus hint in a portal on any side, flipped and clamped to the screen; `hint` variant | [Tooltip](https://design.nish.software/#/components/tooltip) |
339
+ | `Popover`, `menuItemClass()` | Non-modal panel anchored to an element; Escape and outside press close it (with the reason; `dismissOnOutside`); `menuItemClass()` for menu-looking rows inside it | [Popover](https://design.nish.software/#/components/popover) |
340
+ | `DropdownMenu` | Menu of actions behind a button, with `MenuItem`, `MenuLabel`, `MenuSeparator`, `MenuSubHeader` | [DropdownMenu](https://design.nish.software/#/components/dropdown-menu) |
341
+ | `Segmented` | Two to five mutually exclusive choices side by side (xs to md, block, disabled options, per-option tip and tone) | [Segmented](https://design.nish.software/#/components/segmented) |
342
+ | `MediaRow`, `MediaChip`, `MediaThumb` | A list row with a 16:9, round or square thumbnail, a two-line title, meta and detail lines and Live/Offline badges; a pill chip with a thumbnail; the thumbnail alone (https or relative sources only) | [MediaRow](https://design.nish.software/#/components/media-row) |
343
+ | `SplitStage`, `SplitDividers`, `LayoutPresetPicker`, `LayoutPresetIcon` | Up to four panes in a resizable split layout with a flat DOM (panes never move when the layout changes), separator handles, and a preset picker. The layout math is React-free at `@nish/ui/split-layout` | [SplitStage](https://design.nish.software/#/components/split-stage) |
344
+ | `Chip`, `ChipGroup`, `chipClass()` | Multi-select filter chips, suggestions and removable tags; `chipClass()` for links | [Chip](https://design.nish.software/#/components/chip) |
345
+ | `Tabs`, `TabPanel`, `tabClass()` | ARIA tabs (underline or pill, xs to md, block, responsive panes); `tabClass()` for router links | [Tabs](https://design.nish.software/#/components/tabs) |
346
+ | `Inbox` | One list for events from every app: Open, Snoozed and Handled views, source filter, handle and snooze actions; see [Inbox](#inbox) | [Inbox](https://design.nish.software/#/components/inbox) |
347
+ | `AppShell` | The app frame from one `nav` list: AppHeader with desktop tabs and a More menu, NavRail on tablets, BottomNav and MoreSheet on phones, PageContainer, Toaster, ConnectionBanner, LoadingBar and a skip link | [AppShell](https://design.nish.software/#/components/app-shell) |
348
+ | `apiFetch()`, `ApiError`, `configureApi()`, `useResource()` | JSON fetch with typed errors (status 0 for network failures, 401 hook), and a data hook that pauses while the tab is hidden, refetches on reconnect and when visible again, polls, and aborts on unmount | [useResource](https://design.nish.software/#/components/use-resource) |
349
+ | `AppErrorBoundary` | Themed fallback for a render crash or a failed lazy chunk, with Try again and Reload | [AppErrorBoundary](https://design.nish.software/#/components/app-error-boundary) |
350
+ | `FilterBar`, `FilterSheet`, `useUrlState()` | Filter row that becomes a Filters button and bottom sheet when narrow; filters that live in the URL (arrays as repeated keys) with an optional router adapter | [FilterBar](https://design.nish.software/#/components/filter-bar) |
351
+ | `SettingsSection`, `SettingRow`, `NumberField`, `useSaveStatus()` | Settings page rows with a label, hint and live save status; a number field that saves on blur and Enter | [Settings](https://design.nish.software/#/components/settings) |
352
+ | `Combobox` | ARIA 1.2 combobox with a listbox: filter, async search, custom values, keyboard and touch | [Combobox](https://design.nish.software/#/components/combobox) |
353
+ | `BREAKPOINTS`, `PHONE_QUERY`, `NARROW_QUERY`, `usePhone()`, `useNarrow()` | The Tailwind breakpoints as data, and hooks for phone (under 640px) and narrow (under 768px) | [Hooks](https://design.nish.software/#/components/hooks) |
354
+ | `@nish/ui/vite`, `@nish/ui/eslint`, `nish-th-check` | The theme-init Vite plugin, the lint preset and the class checker (Node only) | [Vite plugin and lint](https://design.nish.software/#/components/vite-plugin) |
355
+ | `ThemeToggle`, `useTheme()` | System / Light / Dark control with labels, compact mode, a pill variant and an optional preset picker | [ThemeToggle](https://design.nish.software/#/components/theme-toggle) |
356
+ | `mountThemeToggle()` | `@nish/ui/theme` and `window.nishTheme`: the one-button theme toggle for static pages, optionally with the word | [mountThemeToggle](https://design.nish.software/#/components/mount-theme-toggle) |
357
+ | `showToast()` | `@nish/ui/theme` and `window.nishTheme`: one toast for static pages, with the React toast's timer policy | [showToast](https://design.nish.software/#/components/show-toast) |
358
+ | `@nish/ui/system-canvas` | `SystemCanvas` and its layout and routing helpers, for loading the canvas in a lazy chunk | [SystemCanvas](https://design.nish.software/#/components/system-canvas) |
359
+ | `@nish/ui/chart` | `seriesColor`, `CHART`, `tooltipStyle`, `chartTheme`, `useChartTheme` for any chart library | [Chart colors](https://design.nish.software/#/components/chart) |
360
+ | `@nish/ui/tokens` | Token data for Node scripts, with no React import | [Color](https://design.nish.software/#/color) |
361
+ | `.nish-prose` | Markdown and rich text styles (nish.css, tailwind.css) | [Prose](https://design.nish.software/#/components/prose) |
362
+ | `.nish-skip-link`, `kbd`, `.scrollbar-none` | Base helpers (nish.css, tailwind.css) | [Base utilities](https://design.nish.software/#/components/base-utilities) |
363
+ | `nish-components.css` | Static component classes for pages without React: `.nish-btn`, `.nish-card`, `.nish-badge`, fields, `.nish-seg`, `.nish-chip`, `.nish-callout`, `.nish-stats`, `.nish-table-wrap`, `.nish-meter`, `.nish-disclosure`, `.nish-dot`, `.nish-search`, `.nish-theme-btn` (and `--pill`, `--labelled`), `.nish-toast`, `.nish-glass`, empty and error states. Link it after `nish.css`. | [Static sites](https://design.nish.software/#/static-sites) |
364
+
365
+ Also exported: `cn()` (clsx plus a tailwind-merge that knows the `th-*` colors), the theme
366
+ functions, and `THEMES`, `SCALE`, `COLOR_ROLES`, `SOFT_ROLES`, `HUE_ROLES`, `SHADOWS`, `PRESETS`.
367
+
368
+ ## Inbox
369
+
370
+ `Inbox` renders the list; the page owns the data. Props: `items`, `view` and `onViewChange`
371
+ (open, snoozed, handled), `counts`, `sources`, `source` and `onSourceChange`, the actions
372
+ `onHandle`, `onUnhandle`, `onSnooze(id, until)`, `onUnsnooze` and optional `onHandleAll`, plus
373
+ `loading`, `error`, `onRetry`, `hasMore`, `onLoadMore`, `loadingMore`, `selectedId`, `sourceLabels` and
374
+ `onAction(itemId, actionId)` (returns a Promise; shows each item's `actions` as buttons).
375
+ The event types and `INBOX_SOURCE_LABELS` are exported from `@nish/ui` as well.
376
+
377
+ Apps send events with the React-free client:
378
+
379
+ ```ts
380
+ import { createInboxClient } from '@nish/ui/inbox-client';
381
+
382
+ const inbox = createInboxClient({ source: 'trackers' });
383
+ await inbox.send({ kind: 'price-drop', title: 'Headphones dropped to $298', url, dedupeKey: sku });
384
+ await inbox.resolve(sku); // marks the open item handled
385
+ ```
386
+
387
+ The client never throws and queues up to 200 events while the service is down. It posts to
388
+ `INBOX_URL` (default `http://127.0.0.1:8805`); `INBOX_URL=off` turns it into a no-op for tests and CI.
389
+ Producers import it at runtime, so list `@nish/ui` under `dependencies`.
390
+
391
+ ### Item actions
392
+
393
+ An event can carry up to 3 buttons. Tapping one makes the inbox service call the producer, server to
394
+ server:
395
+
396
+ ```ts
397
+ await inbox.send({
398
+ kind: 'run-failed', title: 'ui: check failed', dedupeKey: runId,
399
+ actions: [{ id: 'rerun', label: 'Re-run', target: 'http://127.0.0.1:8820/actions/rerun' }],
400
+ });
401
+ ```
402
+
403
+ | Field | Rule |
404
+ |---|---|
405
+ | `id` | `/^[a-z0-9][a-z0-9-]{0,31}$/`, unique in the event |
406
+ | `label` | trimmed, 1-40 characters (longer is cut with an ellipsis) |
407
+ | `method` | `'POST'`, may be left out |
408
+ | `target` | `http://127.0.0.1:<port>/…` only: explicit port, no credentials, no `#hash`, ≤ 2000 characters (`isInboxActionTarget`) |
409
+
410
+ The service POSTs an `InboxActionCall` JSON body, `{ itemId, actionId, source, kind, dedupeKey, data }`,
411
+ with the header `X-Inbox-Action: 1` (`INBOX_ACTION_HEADER`), waits at most 8 s (`INBOX_ACTION_TIMEOUT_MS`)
412
+ and follows no redirects. A 2xx answer marks the item handled. Anything else leaves it open. Either way the
413
+ outcome is stored as `item.lastAction` (`InboxActionResult`). A repeat event with the same dedupeKey replaces
414
+ the item's actions.
415
+
416
+ ## An app's own themes: registerThemes
417
+
418
+ Shared themes cover most apps. To offer more, style them with `[data-theme='<id>']`
419
+ blocks that set every `--nish-*` color role, then register them so the theme logic accepts
420
+ the names and knows whether each is dark or light:
421
+
422
+ ```html
423
+ <!-- before theme-init.js, so the first paint knows them -->
424
+ <script>window.__nishExtraThemes = { rose: 'dark', paper: 'light' };</script>
425
+ ```
426
+
427
+ ```ts
428
+ import { registerThemes, initTheme } from '@nish/ui';
429
+ registerThemes({ rose: 'dark', paper: 'light' });
430
+ initTheme();
431
+ ```
432
+
433
+ A registered theme saves to the same cookie. Other apps that do not know the name fall
434
+ back to their default, so pick ids that will not collide with future shared themes.
435
+
436
+ ## Reading tokens in canvas and charts
437
+
438
+ Canvas, SVG libraries and chart code cannot use classes. Read the current value and
439
+ redraw when the theme changes:
440
+
441
+ ```ts
442
+ import { readToken, onThemeChange } from '@nish/ui';
443
+
444
+ const colors = () => ({
445
+ series: Array.from({ length: 8 }, (_, i) => readToken(`chart-${i + 1}`)),
446
+ grid: readToken('line'),
447
+ text: readToken('hi3'),
448
+ });
449
+ const off = onThemeChange(() => chart.update(colors()));
450
+ ```
451
+
452
+ `readToken(name)` returns the value on `<html>` (for example `#8b93ff`). Breakpoints and
453
+ other non-color tokens are in `SCALE` (`SCALE['bp-md']`).
454
+
455
+ ## Accessibility guarantees
456
+
457
+ - **Contrast.** `tools/contrast.mjs` (run by `npm run check`, CI and every release) checks
458
+ every theme: body text at 4.5:1 on bg, surface and elevated; status and accent text at
459
+ 4.5:1 on bg, surface and their own soft tint; every `on-*` color at 4.5:1 on its fill;
460
+ placeholders, chart series, fills and hues at 3:1. The docs site's
461
+ [Themes page](https://design.nish.software/#/themes) shows the same pairs as a matrix.
462
+ - **Target device: Samsung Galaxy Z Fold 7.** Every app built on this package is reviewed
463
+ on it. The cover screen is narrow (about 360–390 CSS px), and unfolded it is a near-square
464
+ ~840px. Components, and every page that uses them, must look right with no horizontal page
465
+ scroll at 360px, at ~840px and at desktop width, in light and dark. `visual-check.mjs`
466
+ checks exactly those sizes by default (`phone-small`, `fold`, `desktop`).
467
+ - **Tap targets.** Buttons, icon buttons, fields and toggles grow to 44px on touch screens
468
+ (`pointer-coarse:`) and stay compact under a mouse.
469
+ - **Tips on touch.** Tooltip and Segmented `tip` open on mouse hover and keyboard focus, never
470
+ on a tap of the control they explain, so a tip never stays pinned over a phone screen. A
471
+ hint term (the trigger itself) still opens on a tap.
472
+ - **Focus.** base.css gives every element a visible `:focus-visible` ring in the accent
473
+ color. Modal traps Tab and returns focus to the opener; Tooltip triggers are focusable.
474
+ - **Reduced motion.** Under `prefers-reduced-motion`, base.css cuts animations and
475
+ transitions to 1ms and the skeleton shimmer stops.
476
+ - **Semantics.** ErrorState is `role="alert"`, toasts are a live region, IconButton requires
477
+ a label, Modal is `role="dialog"` with `aria-modal` and a labelled title.
478
+
479
+ `tools/visual-check.mjs` screenshots any site at desktop and phone sizes in each theme and
480
+ fails on sideways scrolling, clipped text, axe contrast and tap-target violations, console
481
+ errors, missing focus rings and empty screenshots.
482
+
483
+ ## Releasing
484
+
485
+ Releases run in CI (`release.yml`), go to every nish.software app through the fan-out, and are
486
+ published to npm as `nish-ui`. The whole flow, the merge policy and the npm setup:
487
+ [docs/RELEASING.md](docs/RELEASING.md).
488
+
489
+ ## The docs site
490
+
491
+ The site at https://design.nish.software is built from this repo's own `src` and `dist`, so it
492
+ always shows exactly the code being released.
493
+
494
+ ```bash
495
+ npm run dev:site # builds dist/, then serves the site at http://localhost:5191
496
+ npm run build:site # builds dist/, then the static site into site-dist/
497
+ npm run preview:site # serves site-dist/ at http://localhost:5191
498
+ ```
499
+
500
+ `site-dist/` is plain static files with hash routes and relative asset URLs, so it works
501
+ served from any path. Props tables are generated from the TypeScript source at build time
502
+ (`site/docgen.mjs`), so add JSDoc to a prop and it shows up there. Component pages,
503
+ stories and controls live in `site/components/<id>.tsx`, one file per component;
504
+ `site/components/index.ts` lists them in `COMPONENT_DOCS`.
505
+
506
+ ## Repo layout
507
+
508
+ | Path | What |
509
+ |---|---|
510
+ | `src/tokens.mjs` | Every design token. Edit here; the CSS is generated. |
511
+ | `src/theme.ts`, `src/theme-init.js` | Theme switching, and the pre-paint script. |
512
+ | `src/theme-global.ts` | Entry for `dist/theme.global.js` (`window.nishTheme`). |
513
+ | `src/components/` | The React components. |
514
+ | `src/chart.ts` | `@nish/ui/chart`: chart colors and tooltip styles for any chart library. |
515
+ | `src/css/` | `base.css` (page defaults, focus ring, scrollbars, reduced motion, prose, kbd, skip link), `components.css` (the static `nish-*` classes, built to `dist/nish-components.css`) and `fonts.css`. |
516
+ | `scripts/build.mjs` | Builds `dist/`: tokens.css, tailwind.css, nish.css, hashed fonts, theme-init.js, the JS via tsup, and tests theme-init.js and theme.global.js. |
517
+ | `scripts/release.mjs` | `npm run release`: check, version, tag with `dist/`, push. |
518
+ | `.github/workflows/publish.yml`, `tools/npm-publish.mjs` | Publishes a tag to npm as `nish-ui` ([docs/RELEASING.md](docs/RELEASING.md#npm)). |
519
+ | `scripts/bump-consumers.sh` | Moves taarora/arora-home only; the fan-out moves every other repo. |
520
+ | `.github/workflows/fanout.yml`, `tools/fanout/` | The fan-out: opens, settles and merges the bump PRs in every repo of `hosting/fleet.yaml`. |
521
+ | `.github/workflows/fold-check.yml`, `tools/fold-diff.mjs`, `tools/fold-comment.mjs` | The Fold check every app's PRs run: [docs/fold-check.md](docs/fold-check.md). |
522
+ | `site/` | The docs site. |
523
+ | `demo/` | A single-page gallery for quick checks: `npm run dev`, http://localhost:5190. |
524
+ | `tools/contrast.mjs`, `tools/contrast-rules.mjs` | The WCAG check and the pairs it enforces. |
525
+ | `tools/visual-check.mjs` | Screenshot and layout check for any site. Configs: `demo.visual.json`, `site.visual.json` (CI), `site-all.visual.json` (every docs page). |
526
+ | `tools/gallery.mjs` | Turns visual-check runs into a before/after review page. |
527
+ | `CHANGELOG.md` | Every release. |
528
+
529
+ ## Troubleshooting
530
+
531
+ **Component classes are missing (unstyled buttons).** `tailwind.css` has `@source "./"`,
532
+ which tells Tailwind to scan the package's `dist/` for the classes the components use.
533
+ If your setup resolves the package somewhere Tailwind does not follow (some pnpm or
534
+ monorepo layouts), add the path yourself:
535
+
536
+ ```css
537
+ @source '../node_modules/@nish/ui/dist';
538
+ ```
539
+
540
+ **`npm install` fails with "Permission denied (publickey)".** The machine has an SSH key
541
+ GitHub does not accept for this repo. Use the codeload tarball URL from Install, or
542
+ `git config --global url."https://github.com/".insteadOf git@github.com:`.
543
+
544
+ **The page flashes the wrong theme on load.** `theme-init.js` must run before any
545
+ stylesheet and must not be `async`, `defer` or a module. Inline it at the top of `<head>`
546
+ (or load it render-blocking). If the app registers its own themes,
547
+ `window.__nishExtraThemes` must be set before it.
548
+
549
+ **A preset chosen on another site shows as dark or light here.** The page limits itself
550
+ with `data-nish-themes`; that is the intended fallback.
551
+
552
+ **Fonts 404 on a static site after an upgrade.** Font names now carry a hash. Copy every
553
+ file in `dist/files.json`, not a fixed list.
554
+
555
+ ## Versioning
556
+
557
+ Semver on the git tags. A change is **breaking** when an app has to edit its code or
558
+ markup to keep working or keep its look: removing or renaming a token, role, class,
559
+ export, prop or file; changing a component's default; changing the cookie or storage key.
560
+ Before 1.0 a breaking change bumped the minor (0.2.0); from 1.0 it bumps the major, so a major means app code must change, a minor adds, a patch fixes. New roles,
561
+ components, props and files, and color adjustments that keep every contrast check passing,
562
+ are minor or patch. Record every change in `CHANGELOG.md`.