@vjdesigns/vjdesigns-ui 3.4.0 → 3.5.1

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 (113) hide show
  1. package/CHANGELOG.md +178 -0
  2. package/README.md +854 -873
  3. package/dist/ai/llms-full.txt +759 -584
  4. package/dist/ai/llms.txt +4 -1
  5. package/dist/ai/registry.json +481 -27
  6. package/dist/components/data-display/Accordion/Accordion.cjs.js +1 -1
  7. package/dist/components/data-display/Accordion/Accordion.mjs +97 -166
  8. package/dist/components/data-display/Chat/Chat.d.ts +13 -2
  9. package/dist/components/data-display/Collapsible/Collapsible.cjs.js +1 -0
  10. package/dist/components/data-display/Collapsible/Collapsible.d.ts +70 -0
  11. package/dist/components/data-display/Collapsible/Collapsible.mjs +102 -0
  12. package/dist/components/data-display/Collapsible/Collapsible.module.css.cjs.js +1 -0
  13. package/dist/components/data-display/Collapsible/Collapsible.module.css.mjs +8 -0
  14. package/dist/components/data-display/Collapsible/index.d.ts +1 -0
  15. package/dist/components/feedback/Progress/Progress.cjs.js +1 -1
  16. package/dist/components/feedback/Progress/Progress.d.ts +32 -2
  17. package/dist/components/feedback/Progress/Progress.mjs +78 -74
  18. package/dist/components/feedback/Progress/Progress.module.css.cjs.js +1 -1
  19. package/dist/components/feedback/Progress/Progress.module.css.mjs +1 -1
  20. package/dist/components/forms/Radio/Radio.cjs.js +1 -1
  21. package/dist/components/forms/Radio/Radio.mjs +12 -10
  22. package/dist/components/forms/ToggleGroup/ToggleGroup.cjs.js +1 -1
  23. package/dist/components/forms/ToggleGroup/ToggleGroup.d.ts +3 -2
  24. package/dist/components/forms/ToggleGroup/ToggleGroup.mjs +133 -131
  25. package/dist/components/navigation/Toolbar/Toolbar.cjs.js +1 -0
  26. package/dist/components/navigation/Toolbar/Toolbar.d.ts +62 -0
  27. package/dist/components/navigation/Toolbar/Toolbar.mjs +106 -0
  28. package/dist/components/navigation/Toolbar/Toolbar.module.css.cjs.js +1 -0
  29. package/dist/components/navigation/Toolbar/Toolbar.module.css.mjs +11 -0
  30. package/dist/components/navigation/Toolbar/ToolbarContext.cjs.js +1 -0
  31. package/dist/components/navigation/Toolbar/ToolbarContext.d.ts +9 -0
  32. package/dist/components/navigation/Toolbar/ToolbarContext.mjs +4 -0
  33. package/dist/components/navigation/Toolbar/index.d.ts +1 -0
  34. package/dist/components/primitives/CopyButton/CopyButton.cjs.js +1 -0
  35. package/dist/components/primitives/CopyButton/CopyButton.d.ts +39 -0
  36. package/dist/components/primitives/CopyButton/CopyButton.mjs +49 -0
  37. package/dist/components/primitives/CopyButton/index.d.ts +1 -0
  38. package/dist/hooks/useCollapsePresence.cjs.js +1 -0
  39. package/dist/hooks/useCollapsePresence.d.ts +33 -0
  40. package/dist/hooks/useCollapsePresence.mjs +83 -0
  41. package/dist/i18n/en.cjs.js +1 -1
  42. package/dist/i18n/en.mjs +5 -0
  43. package/dist/i18n/types.d.ts +8 -0
  44. package/dist/index.cjs.js +1 -1
  45. package/dist/index.d.ts +3 -0
  46. package/dist/index.mjs +104 -101
  47. package/dist/locales/ar.cjs.js +1 -1
  48. package/dist/locales/ar.mjs +5 -0
  49. package/dist/locales/bn.cjs.js +1 -1
  50. package/dist/locales/bn.mjs +5 -0
  51. package/dist/locales/cs.cjs.js +1 -1
  52. package/dist/locales/cs.mjs +5 -0
  53. package/dist/locales/da.cjs.js +1 -1
  54. package/dist/locales/da.mjs +5 -0
  55. package/dist/locales/de.cjs.js +1 -1
  56. package/dist/locales/de.mjs +5 -0
  57. package/dist/locales/el.cjs.js +1 -1
  58. package/dist/locales/el.mjs +5 -0
  59. package/dist/locales/es.cjs.js +1 -1
  60. package/dist/locales/es.mjs +5 -0
  61. package/dist/locales/fa.cjs.js +1 -1
  62. package/dist/locales/fa.mjs +5 -0
  63. package/dist/locales/fi.cjs.js +1 -1
  64. package/dist/locales/fi.mjs +5 -0
  65. package/dist/locales/fr.cjs.js +1 -1
  66. package/dist/locales/fr.mjs +5 -0
  67. package/dist/locales/he.cjs.js +1 -1
  68. package/dist/locales/he.mjs +5 -0
  69. package/dist/locales/hi.cjs.js +1 -1
  70. package/dist/locales/hi.mjs +5 -0
  71. package/dist/locales/hu.cjs.js +1 -1
  72. package/dist/locales/hu.mjs +5 -0
  73. package/dist/locales/id.cjs.js +1 -1
  74. package/dist/locales/id.mjs +5 -0
  75. package/dist/locales/it.cjs.js +1 -1
  76. package/dist/locales/it.mjs +5 -0
  77. package/dist/locales/ja.cjs.js +1 -1
  78. package/dist/locales/ja.mjs +5 -0
  79. package/dist/locales/ko.cjs.js +1 -1
  80. package/dist/locales/ko.mjs +5 -0
  81. package/dist/locales/nb.cjs.js +1 -1
  82. package/dist/locales/nb.mjs +5 -0
  83. package/dist/locales/nl.cjs.js +1 -1
  84. package/dist/locales/nl.mjs +5 -0
  85. package/dist/locales/pl.cjs.js +1 -1
  86. package/dist/locales/pl.mjs +5 -0
  87. package/dist/locales/pt-BR.cjs.js +1 -1
  88. package/dist/locales/pt-BR.mjs +5 -0
  89. package/dist/locales/ro.cjs.js +1 -1
  90. package/dist/locales/ro.mjs +5 -0
  91. package/dist/locales/ru.cjs.js +1 -1
  92. package/dist/locales/ru.mjs +5 -0
  93. package/dist/locales/sv.cjs.js +1 -1
  94. package/dist/locales/sv.mjs +5 -0
  95. package/dist/locales/th.cjs.js +1 -1
  96. package/dist/locales/th.mjs +5 -0
  97. package/dist/locales/tr.cjs.js +1 -1
  98. package/dist/locales/tr.mjs +5 -0
  99. package/dist/locales/uk.cjs.js +1 -1
  100. package/dist/locales/uk.mjs +5 -0
  101. package/dist/locales/ur.cjs.js +1 -1
  102. package/dist/locales/ur.mjs +5 -0
  103. package/dist/locales/vi.cjs.js +1 -1
  104. package/dist/locales/vi.mjs +5 -0
  105. package/dist/locales/zh-Hans.cjs.js +1 -1
  106. package/dist/locales/zh-Hans.mjs +5 -0
  107. package/dist/locales/zh-Hant.cjs.js +1 -1
  108. package/dist/locales/zh-Hant.mjs +5 -0
  109. package/dist/vjdesigns-ui.css +1 -1
  110. package/package.json +9 -5
  111. package/dist/components/feedback/Toast/Toast.storyHelpers.d.ts +0 -21
  112. package/dist/components/navigation/Sidebar/Sidebar.storyHelpers.d.ts +0 -27
  113. package/dist/components/overlays/Drawer/Drawer.storyHelpers.d.ts +0 -16
@@ -1,8 +1,8 @@
1
- # @vjdesigns/vjdesigns-ui 3.3.0: full reference
1
+ # @vjdesigns/vjdesigns-ui 3.5.1: full reference
2
2
 
3
3
  > Accessible React 19 component library: WCAG 2.2 AA verified (axe on every story, a contrast check on every color pair), 31 languages with right-to-left support, themeable with any brand color (auto-adjusted to stay accessible), tree-shakable, no runtime dependencies besides React.
4
4
 
5
- - Install: `npm install @vjdesigns/vjdesigns-ui` (peer: react, react-dom 18 or 19).
5
+ - Install: `npm install @vjdesigns/vjdesigns-ui` (peer: react, react-dom 19).
6
6
  - Import the stylesheet once: `import "@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css";`
7
7
  - Import components from the package root: `import { Button, Field, Input } from "@vjdesigns/vjdesigns-ui";`
8
8
  - Theme: wrap the app in `<Theme brand="blue" | "purple" | ... | "#hex" mode="light" | "dark" accent="brand" | "lime" | "#hex">`.
@@ -12,583 +12,597 @@
12
12
 
13
13
  # Guide: Installation
14
14
 
15
- Install the package along with React and React DOM (version 18 or 19), which the components need in order to render:
16
-
17
- ```bash
18
- npm install @vjdesigns/vjdesigns-ui react react-dom
19
- ```
20
-
21
- If your project already uses React, you only need the first package:
22
-
23
- ```bash
24
- npm install @vjdesigns/vjdesigns-ui
25
- ```
26
-
27
- ### Import the styles
28
-
29
- The component styles and shared design tokens ship as a separate stylesheet. Import it **once** at your app's entry point, or the components will render unstyled.
30
-
31
- **React:** in `main.tsx` (or `App.tsx`)
32
-
33
- ```ts
34
- import "@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css";
35
- ```
36
-
37
- **Angular:** add it to the `styles` array in `angular.json`
38
-
39
- ```json
40
- "styles": [
41
- "node_modules/@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css",
42
- "src/styles.css"
43
- ]
44
- ```
45
-
46
- **Vue:** in `main.ts`
47
-
48
- ```ts
49
- import "@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css";
15
+ Install the package along with React and React DOM. The library requires **React 19**, which the components need in order to render:
16
+
17
+ ```bash
18
+ npm install @vjdesigns/vjdesigns-ui react react-dom
19
+ ```
20
+
21
+ If your project already uses React, you only need the first package:
22
+
23
+ ```bash
24
+ npm install @vjdesigns/vjdesigns-ui
25
+ ```
26
+
27
+ ### Browser support
28
+
29
+ The components support the current and previous major versions of evergreen browsers, with these minimums:
30
+
31
+ | Browser | Minimum version |
32
+ | --- | --- |
33
+ | Chrome, Edge, and other Chromium browsers | 111 |
34
+ | Firefox | 121 |
35
+ | Safari (macOS and iOS) | 16.2 |
36
+
37
+ These are set by the CSS the components rely on: `color-mix()`, container queries, `:has()` (which draws some keyboard focus rings), and the `inert` attribute. Internet Explorer and legacy (non-Chromium) Edge aren't supported.
38
+
39
+ A few newer features are used only where available, with a fallback elsewhere: `field-sizing` for auto-growing `Textarea` (measured in JavaScript otherwise), the `scrollend` event in `Carousel`, and `hidden="until-found"` for find-in-page in `Accordion` and `Collapsible`.
40
+
41
+ ### Import the styles
42
+
43
+ The component styles and shared design tokens ship as a separate stylesheet. Import it **once** at your app's entry point, or the components will render unstyled.
44
+
45
+ **React:** in `main.tsx` (or `App.tsx`)
46
+
47
+ ```ts
48
+ import "@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css";
49
+ ```
50
+
51
+ **Angular:** add it to the `styles` array in `angular.json`
52
+
53
+ ```json
54
+ "styles": [
55
+ "node_modules/@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css",
56
+ "src/styles.css"
57
+ ]
58
+ ```
59
+
60
+ **Vue:** in `main.ts`
61
+
62
+ ```ts
63
+ import "@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css";
50
64
  ```
51
65
 
52
66
  # Guide: Usage
53
67
 
54
- The components are built with React. You can use them directly in a React project. In Angular or Vue, you mount them inside a small wrapper component, as shown below.
55
-
56
- ### React
57
-
58
- ```tsx
59
- import { useState } from "react";
60
- import { Button, CheckBox } from "@vjdesigns/vjdesigns-ui";
61
-
62
- export function SignupForm() {
63
- const [accepted, setAccepted] = useState(false);
64
-
65
- return (
66
- <form>
67
- <CheckBox
68
- label="Accept terms"
69
- checked={accepted}
70
- onCheckedChange={setAccepted}
71
- />
72
- <Button
73
- variant="solid"
74
- tone="primary"
75
- size="md"
76
- disabled={!accepted}
77
- onClick={() => console.log("Submitted")}
78
- >
79
- Submit
80
- </Button>
81
- </form>
82
- );
83
- }
84
- ```
85
-
86
- ### Next.js (App Router) and React Server Components
87
-
88
- The library works in Server Components. Interactive components (anything with state, effects, or context: `Button`, `DataGrid`, `Modal`, ...) are marked `"use client"`, so you can render them from a Server Component like any client component. Utilities (`cx`, `sortRows`, `createBrandPalette`, `getLocaleDirection`, ...) and the locale catalogs have no directive, so you can call or read them on the server too. Every component also renders on the server for the first paint.
89
-
90
- Put the providers in a small client file of your own, and render it from the root layout:
91
-
92
- ```tsx
93
- // app/providers.tsx
94
- "use client";
95
- import { LocaleProvider, ToastProvider } from "@vjdesigns/vjdesigns-ui";
96
- import es from "@vjdesigns/vjdesigns-ui/locales/es";
97
- import type { ReactNode } from "react";
98
-
99
- export function Providers({ children }: { children: ReactNode }) {
100
- return (
101
- <LocaleProvider locale="es" messages={es}>
102
- <ToastProvider>{children}</ToastProvider>
103
- </LocaleProvider>
104
- );
105
- }
106
- ```
107
-
108
- ```tsx
109
- // app/layout.tsx (a Server Component)
110
- import "@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css";
111
- import { getLocaleDirection } from "@vjdesigns/vjdesigns-ui";
112
- import { Providers } from "./providers";
113
-
114
- export default function RootLayout({ children }: { children: React.ReactNode }) {
115
- return (
116
- <html lang="es" dir={getLocaleDirection("es")}>
117
- <body>
118
- <Providers>{children}</Providers>
119
- </body>
120
- </html>
121
- );
122
- }
123
- ```
124
-
125
- Two rules of Server Components to keep in mind:
126
-
127
- - **Functions can't be passed from a Server Component to a client one.** That includes event handlers (`onClick`), DataGrid columns with `cell` or `value` functions, and the locale catalogs themselves (their plural messages are functions, which is why `LocaleProvider` goes in the client providers file above). Render those components from your own `"use client"` file.
128
- - **Compound parts can't be reached with a dot from a Server Component** (`Tabs.List`, `Menu.Item`): Next.js reports "You cannot dot into a client module". Use them inside a `"use client"` file, or use the named exports where they exist (`CardHeader`, `CardBody`, `NavbarBrand`, ...).
129
-
130
- ### Angular
131
-
132
- Make a standalone wrapper that renders the React component into its host element. The wrapper uses `createElement`, so you don't need to change your JSX or TSX settings.
133
-
134
- ```ts
135
- // vj-button.component.ts
136
- import {
137
- AfterViewInit,
138
- Component,
139
- ElementRef,
140
- EventEmitter,
141
- Input,
142
- OnChanges,
143
- OnDestroy,
144
- Output,
145
- ViewChild,
146
- } from "@angular/core";
147
- import { createElement, type MouseEvent as ReactMouseEvent, type ReactElement } from "react";
148
- import { createRoot, Root } from "react-dom/client";
149
- import {
150
- Button,
151
- type ButtonProps,
152
- type ButtonVariant,
153
- type Size,
154
- type Tone,
155
- } from "@vjdesigns/vjdesigns-ui";
156
-
157
- // Button has overloaded types (for `href` and `as`). Narrowing it here lets createElement type-check.
158
- const ReactButton = Button as (props: ButtonProps) => ReactElement;
159
-
160
- @Component({
161
- selector: "vj-button",
162
- standalone: true,
163
- template: `<span #host></span>`,
164
- })
165
- export class VjButtonComponent implements AfterViewInit, OnChanges, OnDestroy {
166
- @ViewChild("host", { static: true }) host!: ElementRef<HTMLElement>;
167
-
168
- @Input() label = "";
169
- @Input() variant: ButtonVariant = "solid";
170
- @Input() tone: Tone = "primary";
171
- @Input() size: Size = "md";
172
- @Input() disabled = false;
173
- @Output() clicked = new EventEmitter<MouseEvent>();
174
-
175
- private root?: Root;
176
-
177
- ngAfterViewInit() {
178
- this.root = createRoot(this.host.nativeElement);
179
- this.render();
180
- }
181
-
182
- ngOnChanges() {
183
- this.render();
184
- }
185
-
186
- ngOnDestroy() {
187
- this.root?.unmount();
188
- }
189
-
190
- private render() {
191
- this.root?.render(
192
- createElement(
193
- ReactButton,
194
- {
195
- variant: this.variant,
196
- tone: this.tone,
197
- size: this.size,
198
- disabled: this.disabled,
199
- onClick: (event: ReactMouseEvent) => this.clicked.emit(event.nativeEvent),
200
- },
201
- this.label // the button's text is passed as children
202
- )
203
- );
204
- }
205
- }
206
- ```
207
-
208
- Import the wrapper wherever you need it:
209
-
210
- ```ts
211
- // app.component.ts
212
- import { Component } from "@angular/core";
213
- import { VjButtonComponent } from "./vj-button.component";
214
-
215
- @Component({
216
- selector: "app-root",
217
- standalone: true,
218
- imports: [VjButtonComponent],
219
- template: `<vj-button label="Submit" tone="primary" (clicked)="onSubmit()" />`,
220
- })
221
- export class AppComponent {
222
- onSubmit() {
223
- console.log("Submitted");
224
- }
225
- }
226
- ```
227
-
228
- ### Vue 3
229
-
230
- Make a wrapper component that mounts the React component when it loads and re-renders it whenever its props change.
231
-
232
- ```vue
233
- <!-- VjButton.vue -->
234
- <script setup lang="ts">
235
- import { onBeforeUnmount, onMounted, ref, watch } from "vue";
236
- import { createElement, type MouseEvent as ReactMouseEvent, type ReactElement } from "react";
237
- import { createRoot, type Root } from "react-dom/client";
238
- import {
239
- Button,
240
- type ButtonProps,
241
- type ButtonVariant,
242
- type Size,
243
- type Tone,
244
- } from "@vjdesigns/vjdesigns-ui";
245
-
246
- // Button has overloaded types (for `href` and `as`). Narrowing it here lets createElement type-check.
247
- const ReactButton = Button as (props: ButtonProps) => ReactElement;
248
-
249
- const props = withDefaults(
250
- defineProps<{
251
- label: string;
252
- variant?: ButtonVariant;
253
- tone?: Tone;
254
- size?: Size;
255
- disabled?: boolean;
256
- }>(),
257
- { variant: "solid", tone: "primary", size: "md", disabled: false }
258
- );
259
-
260
- const emit = defineEmits<{ click: [event: MouseEvent] }>();
261
-
262
- const host = ref<HTMLElement | null>(null);
263
- let root: Root | undefined;
264
-
265
- function render() {
266
- root?.render(
267
- createElement(
268
- ReactButton,
269
- {
270
- variant: props.variant,
271
- tone: props.tone,
272
- size: props.size,
273
- disabled: props.disabled,
274
- onClick: (event: ReactMouseEvent) => emit("click", event.nativeEvent),
275
- },
276
- props.label // the button's text is passed as children
277
- )
278
- );
279
- }
280
-
281
- onMounted(() => {
282
- root = createRoot(host.value!);
283
- render();
284
- });
285
-
286
- watch(() => ({ ...props }), render);
287
-
288
- onBeforeUnmount(() => root?.unmount());
289
- </script>
290
-
291
- <template>
292
- <span ref="host" />
293
- </template>
294
- ```
295
-
296
- Use it like any other Vue component:
297
-
298
- ```vue
299
- <script setup lang="ts">
300
- import VjButton from "./VjButton.vue";
301
-
302
- const onSubmit = () => console.log("Submitted");
303
- </script>
304
-
305
- <template>
306
- <VjButton label="Submit" tone="primary" @click="onSubmit" />
307
- </template>
308
- ```
309
-
68
+ The components are built with React. You can use them directly in a React project. In Angular or Vue, you mount them inside a small wrapper component, as shown below.
69
+
70
+ ### React
71
+
72
+ ```tsx
73
+ import { useState } from "react";
74
+ import { Button, CheckBox } from "@vjdesigns/vjdesigns-ui";
75
+
76
+ export function SignupForm() {
77
+ const [accepted, setAccepted] = useState(false);
78
+
79
+ return (
80
+ <form>
81
+ <CheckBox
82
+ label="Accept terms"
83
+ checked={accepted}
84
+ onCheckedChange={setAccepted}
85
+ />
86
+ <Button
87
+ variant="solid"
88
+ tone="primary"
89
+ size="md"
90
+ disabled={!accepted}
91
+ onClick={() => console.log("Submitted")}
92
+ >
93
+ Submit
94
+ </Button>
95
+ </form>
96
+ );
97
+ }
98
+ ```
99
+
100
+ ### Next.js (App Router) and React Server Components
101
+
102
+ The library works in Server Components. Interactive components (anything with state, effects, or context: `Button`, `DataGrid`, `Modal`, ...) are marked `"use client"`, so you can render them from a Server Component like any client component. Utilities (`cx`, `sortRows`, `createBrandPalette`, `getLocaleDirection`, ...) and the locale catalogs have no directive, so you can call or read them on the server too. Every component also renders on the server for the first paint.
103
+
104
+ Put the providers in a small client file of your own, and render it from the root layout:
105
+
106
+ ```tsx
107
+ // app/providers.tsx
108
+ "use client";
109
+ import { LocaleProvider, ToastProvider } from "@vjdesigns/vjdesigns-ui";
110
+ import es from "@vjdesigns/vjdesigns-ui/locales/es";
111
+ import type { ReactNode } from "react";
112
+
113
+ export function Providers({ children }: { children: ReactNode }) {
114
+ return (
115
+ <LocaleProvider locale="es" messages={es}>
116
+ <ToastProvider>{children}</ToastProvider>
117
+ </LocaleProvider>
118
+ );
119
+ }
120
+ ```
121
+
122
+ ```tsx
123
+ // app/layout.tsx (a Server Component)
124
+ import "@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css";
125
+ import { getLocaleDirection } from "@vjdesigns/vjdesigns-ui";
126
+ import { Providers } from "./providers";
127
+
128
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
129
+ return (
130
+ <html lang="es" dir={getLocaleDirection("es")}>
131
+ <body>
132
+ <Providers>{children}</Providers>
133
+ </body>
134
+ </html>
135
+ );
136
+ }
137
+ ```
138
+
139
+ Two rules of Server Components to keep in mind:
140
+
141
+ - **Functions can't be passed from a Server Component to a client one.** That includes event handlers (`onClick`), DataGrid columns with `cell` or `value` functions, and the locale catalogs themselves (their plural messages are functions, which is why `LocaleProvider` goes in the client providers file above). Render those components from your own `"use client"` file.
142
+ - **Compound parts can't be reached with a dot from a Server Component** (`Tabs.List`, `Menu.Item`): Next.js reports "You cannot dot into a client module". Use them inside a `"use client"` file, or use the named exports where they exist (`CardHeader`, `CardBody`, `NavbarBrand`, ...).
143
+
144
+ ### Angular
145
+
146
+ Make a standalone wrapper that renders the React component into its host element. The wrapper uses `createElement`, so you don't need to change your JSX or TSX settings.
147
+
148
+ ```ts
149
+ // vj-button.component.ts
150
+ import {
151
+ AfterViewInit,
152
+ Component,
153
+ ElementRef,
154
+ EventEmitter,
155
+ Input,
156
+ OnChanges,
157
+ OnDestroy,
158
+ Output,
159
+ ViewChild,
160
+ } from "@angular/core";
161
+ import { createElement, type MouseEvent as ReactMouseEvent, type ReactElement } from "react";
162
+ import { createRoot, Root } from "react-dom/client";
163
+ import {
164
+ Button,
165
+ type ButtonProps,
166
+ type ButtonVariant,
167
+ type Size,
168
+ type Tone,
169
+ } from "@vjdesigns/vjdesigns-ui";
170
+
171
+ // Button has overloaded types (for `href` and `as`). Narrowing it here lets createElement type-check.
172
+ const ReactButton = Button as (props: ButtonProps) => ReactElement;
173
+
174
+ @Component({
175
+ selector: "vj-button",
176
+ standalone: true,
177
+ template: `<span #host></span>`,
178
+ })
179
+ export class VjButtonComponent implements AfterViewInit, OnChanges, OnDestroy {
180
+ @ViewChild("host", { static: true }) host!: ElementRef<HTMLElement>;
181
+
182
+ @Input() label = "";
183
+ @Input() variant: ButtonVariant = "solid";
184
+ @Input() tone: Tone = "primary";
185
+ @Input() size: Size = "md";
186
+ @Input() disabled = false;
187
+ @Output() clicked = new EventEmitter<MouseEvent>();
188
+
189
+ private root?: Root;
190
+
191
+ ngAfterViewInit() {
192
+ this.root = createRoot(this.host.nativeElement);
193
+ this.render();
194
+ }
195
+
196
+ ngOnChanges() {
197
+ this.render();
198
+ }
199
+
200
+ ngOnDestroy() {
201
+ this.root?.unmount();
202
+ }
203
+
204
+ private render() {
205
+ this.root?.render(
206
+ createElement(
207
+ ReactButton,
208
+ {
209
+ variant: this.variant,
210
+ tone: this.tone,
211
+ size: this.size,
212
+ disabled: this.disabled,
213
+ onClick: (event: ReactMouseEvent) => this.clicked.emit(event.nativeEvent),
214
+ },
215
+ this.label // the button's text is passed as children
216
+ )
217
+ );
218
+ }
219
+ }
220
+ ```
221
+
222
+ Import the wrapper wherever you need it:
223
+
224
+ ```ts
225
+ // app.component.ts
226
+ import { Component } from "@angular/core";
227
+ import { VjButtonComponent } from "./vj-button.component";
228
+
229
+ @Component({
230
+ selector: "app-root",
231
+ standalone: true,
232
+ imports: [VjButtonComponent],
233
+ template: `<vj-button label="Submit" tone="primary" (clicked)="onSubmit()" />`,
234
+ })
235
+ export class AppComponent {
236
+ onSubmit() {
237
+ console.log("Submitted");
238
+ }
239
+ }
240
+ ```
241
+
242
+ ### Vue 3
243
+
244
+ Make a wrapper component that mounts the React component when it loads and re-renders it whenever its props change.
245
+
246
+ ```vue
247
+ <!-- VjButton.vue -->
248
+ <script setup lang="ts">
249
+ import { onBeforeUnmount, onMounted, ref, watch } from "vue";
250
+ import { createElement, type MouseEvent as ReactMouseEvent, type ReactElement } from "react";
251
+ import { createRoot, type Root } from "react-dom/client";
252
+ import {
253
+ Button,
254
+ type ButtonProps,
255
+ type ButtonVariant,
256
+ type Size,
257
+ type Tone,
258
+ } from "@vjdesigns/vjdesigns-ui";
259
+
260
+ // Button has overloaded types (for `href` and `as`). Narrowing it here lets createElement type-check.
261
+ const ReactButton = Button as (props: ButtonProps) => ReactElement;
262
+
263
+ const props = withDefaults(
264
+ defineProps<{
265
+ label: string;
266
+ variant?: ButtonVariant;
267
+ tone?: Tone;
268
+ size?: Size;
269
+ disabled?: boolean;
270
+ }>(),
271
+ { variant: "solid", tone: "primary", size: "md", disabled: false }
272
+ );
273
+
274
+ const emit = defineEmits<{ click: [event: MouseEvent] }>();
275
+
276
+ const host = ref<HTMLElement | null>(null);
277
+ let root: Root | undefined;
278
+
279
+ function render() {
280
+ root?.render(
281
+ createElement(
282
+ ReactButton,
283
+ {
284
+ variant: props.variant,
285
+ tone: props.tone,
286
+ size: props.size,
287
+ disabled: props.disabled,
288
+ onClick: (event: ReactMouseEvent) => emit("click", event.nativeEvent),
289
+ },
290
+ props.label // the button's text is passed as children
291
+ )
292
+ );
293
+ }
294
+
295
+ onMounted(() => {
296
+ root = createRoot(host.value!);
297
+ render();
298
+ });
299
+
300
+ watch(() => ({ ...props }), render);
301
+
302
+ onBeforeUnmount(() => root?.unmount());
303
+ </script>
304
+
305
+ <template>
306
+ <span ref="host" />
307
+ </template>
308
+ ```
309
+
310
+ Use it like any other Vue component:
311
+
312
+ ```vue
313
+ <script setup lang="ts">
314
+ import VjButton from "./VjButton.vue";
315
+
316
+ const onSubmit = () => console.log("Submitted");
317
+ </script>
318
+
319
+ <template>
320
+ <VjButton label="Submit" tone="primary" @click="onSubmit" />
321
+ </template>
322
+ ```
323
+
310
324
  > **Tip:** Wrap `CheckBox` and any other component the same way. Pass its props into `createElement`, and send its callbacks back out as Angular outputs or Vue emits. For `CheckBox`, that means sending `onCheckedChange` back out.
311
325
 
312
326
  # Guide: Theming
313
327
 
314
- Wrap any part of your app in `Theme` to set the color mode, brand palette, and accent for everything inside it:
315
-
316
- ```tsx
317
- import { Theme, Button } from "@vjdesigns/vjdesigns-ui";
318
-
319
- <Theme mode="dark" brand="purple" fill>
320
- <Button>Dark, purple button</Button>
321
- </Theme>
322
- ```
323
-
324
- | Prop | Type | Default | Description |
325
- | --- | --- | --- | --- |
326
- | `mode` | `"light" \| "dark"` | inherited | Color mode for everything inside. |
327
- | `brand` | `"black" \| "blue" \| "gold" \| "green" \| "purple"`, a hex color, or `{ light, dark }` | inherited | Brand palette for buttons, links, focus rings and indicators. |
328
- | `accent` | `"brand" | "lime"`, a hex color, or `{ light, dark }` | inherited (the brand's own) | The bright highlight on badges, switches, progress bars, sliders, steppers, and active navigation. |
329
- | `fill` | `boolean` | `false` | Paints the theme's background and text color on the wrapper. |
330
-
331
- Outside React (or to theme the whole page), set the attributes on `<html>` instead:
332
-
333
- ```html
334
- <html data-theme="dark" data-brand="purple" data-accent="lime">
335
- ```
336
-
337
- ### Accent color
338
-
339
- The accent is the energetic highlight: badges, switches, progress bars, sliders, steppers, and the active link in the Navbar. By default it follows the brand, as a bright shade of the brand's own color, so it always fits:
340
-
341
- | Brand | Default accent |
342
- | --- | --- |
343
- | `blue` (default) | sky blue `#76c7ff` |
344
- | `purple` | lavender `#c0b0ff` |
345
- | `gold` | amber `#f5ad5f` |
346
- | `green` | mint `#72d4ad` |
347
- | `black` | lime `#c8f031` (black has no hue to build on) |
348
- | a custom hex | generated from that color |
349
-
350
- To choose a different one:
351
-
352
- ```tsx
353
- <Theme accent="lime">…</Theme> // the original bright yellow-green ("volt", its former name, still works)
354
- <Theme accent="#ff6b00">…</Theme> // any color
355
- <Theme accent="brand">…</Theme> // back to the brand's own, inside an area with another accent
356
- ```
357
-
358
- Accents always carry dark text. A color too dark for that is lightened (same hue) just enough to meet WCAG AA, with a warning in development. An accent you set also holds inside nested brands. In CSS, `accentCss("name", "#ff6b00")` generates a `[data-accent="name"]` rule, like `brandCss` below.
359
-
360
- ### Custom brand colors
361
-
362
- Pass any hex color as `brand` and a full palette is generated for both modes:
363
-
364
- ```tsx
365
- <Theme brand="#e11d48">…</Theme>
366
- <Theme brand={{ light: "#4338ca", dark: "#f472b6" }}>…</Theme>
367
- ```
368
-
369
- Every generated palette meets WCAG 2.2 AA. A single color is used exactly as given in the mode where it has enough contrast (dark colors in light mode, light colors in dark mode), and the other mode gets a matching shade of the same hue. If a color doesn't have enough contrast (for example, a mid-tone that fails in both modes), its lightness is shifted just enough to pass, and a warning is logged in development.
370
-
371
- To define a brand in CSS instead (for the whole page, applied before any JavaScript runs), generate a stylesheet rule with `brandCss`:
372
-
373
- ```ts
374
- import { brandCss } from "@vjdesigns/vjdesigns-ui";
375
-
376
- brandCss("acme", "#e11d48"); // '[data-brand="acme"] { --brand-light-primary: … }'
377
- ```
378
-
379
- Add the rule to your stylesheet and use `<html data-brand="acme">`. `createBrandPalette(color)` returns the generated colors as an object, if you need them directly.
380
-
381
- ### Tailwind CSS
382
-
383
- A Tailwind CSS v4 preset turns the design tokens into utilities, so your own layouts match the components. Import it after Tailwind in your CSS, and keep importing the library's stylesheet as usual:
384
-
385
- ```css
386
- @import "tailwindcss";
387
- @import "@vjdesigns/vjdesigns-ui/tailwind.css";
388
- ```
389
-
390
- ```tsx
391
- <section className="bg-surface text-text rounded-xl shadow-md p-6">
392
- <h2 className="font-display text-2xl tracking-tight">Season stats</h2>
393
- <p className="text-text-muted">Updated after every game.</p>
394
- <span className="bg-accent text-on-accent rounded-control px-3">New</span>
395
- </section>
396
- ```
397
-
398
- Every utility points at a token (`bg-primary` is `var(--color-primary)`), so Tailwind classes follow `Theme`, `data-theme`, `data-brand`, and `data-accent` exactly like the components, with no `dark:` variants needed.
399
-
400
- | Group | Utilities |
401
- | --- | --- |
402
- | Colors | `bg-`, `text-`, `border-`, `ring-`, … with `bg`, `surface` (`-raised`, `-sunken`, `-hover`, `-active`), `overlay`, `text` (`-muted`, `-disabled`, `-inverse`), `border` (`-strong`, `-input`), `focus-ring`, `link-visited`; and for `primary`, `accent`, `success`, `warning`, `danger`, `info`, `neutral`: the solid color, `-hover`, `-active`, `on-…` (text on the solid), `-subtle`, `-subtle-hover`, `-subtle-text`, `-border`. Opacity modifiers work (`bg-primary/50`). |
403
- | Charts | `bg-chart-1` to `bg-chart-8`, for fills only, in that order. Slots 3 to 5 are under 3:1 on white, so pair them with a legend, labels, or a data table. |
404
- | Type | `font-display` (headings, buttons, labels, numbers), `font-body`, `font-mono`; `text-xs` to `text-6xl` (plus `text-md`); `font-regular` to `font-black`; `leading-tight`, `-snug`, `-normal`, `-relaxed`; `tracking-tight`, `-normal`, `-wide`, `-caps` |
405
- | Shape | `rounded-control` (pill controls), `rounded-field` (text fields), `rounded-xs` to `rounded-2xl`, `rounded-pill` |
406
- | Depth | `shadow-xs` to `shadow-xl`, `blur-sm`, `blur-lg` |
407
- | Motion | `ease-spring` (enter and press), `ease-standard`, `ease-in`, `ease-out`; `duration-instant`, `-fast`, `-normal`, `-slow` (0ms under reduced motion) |
408
- | Sizes | `h-control-sm`, `-md`, `-lg` (and `w-`, `min-h-`, …), `size-target` (the 24px minimum pointer target), `max-w-xs` to `max-w-2xl` and `@xs:` to `@2xl:` container queries |
409
- | Layers | `z-sticky`, `z-overlay`, `z-modal`, `z-popover`, `z-dropdown`, `z-toast`, `z-tooltip` |
410
- | Dark mode | `dark:` follows `data-theme="dark"`, not the OS setting. |
411
-
412
- Tailwind's numeric spacing (`p-4` = 1rem) already matches the 4px token scale, and the breakpoints (`sm:` to `2xl:`) are the same as Tailwind's.
413
-
414
- Some Tailwind names change meaning with the preset: `rounded-*`, `shadow-*`, `blur-sm`/`-lg`, `ease-in`/`-out`, `font-mono`, `font-medium` to `font-black`, `leading-*`, and the `text-*` sizes take the library's values (for example, `rounded-md` is 12px and `font-black` is 800). So do the containers: `max-w-md` and `@md:` are 48rem, not Tailwind's 28rem. The library's stylesheet already gives some of these names its own values once it's loaded, even without the preset; the preset keeps the utilities and the container queries consistent.
415
-
416
- For text contrast, use the pairs the components use: `text-text` or `text-text-muted` on `bg-bg`, `bg-surface`, and the other surfaces; `text-on-primary` on `bg-primary` (likewise `on-accent`, `on-success`, …); `text-primary-subtle-text` on `bg-primary-subtle` (likewise for each tone). These pairs meet WCAG 2.2 AA in both themes and every brand. Don't use accent or chart colors for text.
417
-
328
+ Wrap any part of your app in `Theme` to set the color mode, brand palette, and accent for everything inside it:
329
+
330
+ ```tsx
331
+ import { Theme, Button } from "@vjdesigns/vjdesigns-ui";
332
+
333
+ <Theme mode="dark" brand="purple" fill>
334
+ <Button>Dark, purple button</Button>
335
+ </Theme>
336
+ ```
337
+
338
+ | Prop | Type | Default | Description |
339
+ | --- | --- | --- | --- |
340
+ | `mode` | `"light" \| "dark"` | inherited | Color mode for everything inside. |
341
+ | `brand` | `"black" \| "blue" \| "gold" \| "green" \| "purple"`, a hex color, or `{ light, dark }` | inherited | Brand palette for buttons, links, focus rings and indicators. |
342
+ | `accent` | `"brand" | "lime"`, a hex color, or `{ light, dark }` | inherited (the brand's own) | The bright highlight on badges, switches, progress bars, sliders, steppers, and active navigation. |
343
+ | `fill` | `boolean` | `false` | Paints the theme's background and text color on the wrapper. |
344
+
345
+ Outside React (or to theme the whole page), set the attributes on `<html>` instead:
346
+
347
+ ```html
348
+ <html data-theme="dark" data-brand="purple" data-accent="lime">
349
+ ```
350
+
351
+ ### Accent color
352
+
353
+ The accent is the energetic highlight: badges, switches, progress bars, sliders, steppers, and the active link in the Navbar. By default it follows the brand, as a bright shade of the brand's own color, so it always fits:
354
+
355
+ | Brand | Default accent |
356
+ | --- | --- |
357
+ | `blue` (default) | sky blue `#76c7ff` |
358
+ | `purple` | lavender `#c0b0ff` |
359
+ | `gold` | amber `#f5ad5f` |
360
+ | `green` | mint `#72d4ad` |
361
+ | `black` | lime `#c8f031` (black has no hue to build on) |
362
+ | a custom hex | generated from that color |
363
+
364
+ To choose a different one:
365
+
366
+ ```tsx
367
+ <Theme accent="lime">…</Theme> // the original bright yellow-green ("volt", its former name, still works)
368
+ <Theme accent="#ff6b00">…</Theme> // any color
369
+ <Theme accent="brand">…</Theme> // back to the brand's own, inside an area with another accent
370
+ ```
371
+
372
+ Accents always carry dark text. A color too dark for that is lightened (same hue) just enough to meet WCAG AA, with a warning in development. An accent you set also holds inside nested brands. In CSS, `accentCss("name", "#ff6b00")` generates a `[data-accent="name"]` rule, like `brandCss` below.
373
+
374
+ ### Custom brand colors
375
+
376
+ Pass any hex color as `brand` and a full palette is generated for both modes:
377
+
378
+ ```tsx
379
+ <Theme brand="#e11d48">…</Theme>
380
+ <Theme brand={{ light: "#4338ca", dark: "#f472b6" }}>…</Theme>
381
+ ```
382
+
383
+ Every generated palette meets WCAG 2.2 AA. A single color is used exactly as given in the mode where it has enough contrast (dark colors in light mode, light colors in dark mode), and the other mode gets a matching shade of the same hue. If a color doesn't have enough contrast (for example, a mid-tone that fails in both modes), its lightness is shifted just enough to pass, and a warning is logged in development.
384
+
385
+ To define a brand in CSS instead (for the whole page, applied before any JavaScript runs), generate a stylesheet rule with `brandCss`:
386
+
387
+ ```ts
388
+ import { brandCss } from "@vjdesigns/vjdesigns-ui";
389
+
390
+ brandCss("acme", "#e11d48"); // '[data-brand="acme"] { --brand-light-primary: … }'
391
+ ```
392
+
393
+ Add the rule to your stylesheet and use `<html data-brand="acme">`. `createBrandPalette(color)` returns the generated colors as an object, if you need them directly.
394
+
395
+ ### Tailwind CSS
396
+
397
+ A Tailwind CSS v4 preset turns the design tokens into utilities, so your own layouts match the components. Import it after Tailwind in your CSS, and keep importing the library's stylesheet as usual:
398
+
399
+ ```css
400
+ @import "tailwindcss";
401
+ @import "@vjdesigns/vjdesigns-ui/tailwind.css";
402
+ ```
403
+
404
+ ```tsx
405
+ <section className="bg-surface text-text rounded-xl shadow-md p-6">
406
+ <h2 className="font-display text-2xl tracking-tight">Season stats</h2>
407
+ <p className="text-text-muted">Updated after every game.</p>
408
+ <span className="bg-accent text-on-accent rounded-control px-3">New</span>
409
+ </section>
410
+ ```
411
+
412
+ Every utility points at a token (`bg-primary` is `var(--color-primary)`), so Tailwind classes follow `Theme`, `data-theme`, `data-brand`, and `data-accent` exactly like the components, with no `dark:` variants needed.
413
+
414
+ | Group | Utilities |
415
+ | --- | --- |
416
+ | Colors | `bg-`, `text-`, `border-`, `ring-`, … with `bg`, `surface` (`-raised`, `-sunken`, `-hover`, `-active`), `overlay`, `text` (`-muted`, `-disabled`, `-inverse`), `border` (`-strong`, `-input`), `focus-ring`, `link-visited`; and for `primary`, `accent`, `success`, `warning`, `danger`, `info`, `neutral`: the solid color, `-hover`, `-active`, `on-…` (text on the solid), `-subtle`, `-subtle-hover`, `-subtle-text`, `-border`. Opacity modifiers work (`bg-primary/50`). |
417
+ | Charts | `bg-chart-1` to `bg-chart-8`, for fills only, in that order. Slots 3 to 5 are under 3:1 on white, so pair them with a legend, labels, or a data table. |
418
+ | Type | `font-display` (headings, buttons, labels, numbers), `font-body`, `font-mono`; `text-xs` to `text-6xl` (plus `text-md`); `font-regular` to `font-black`; `leading-tight`, `-snug`, `-normal`, `-relaxed`; `tracking-tight`, `-normal`, `-wide`, `-caps` |
419
+ | Shape | `rounded-control` (pill controls), `rounded-field` (text fields), `rounded-xs` to `rounded-2xl`, `rounded-pill` |
420
+ | Depth | `shadow-xs` to `shadow-xl`, `blur-sm`, `blur-lg` |
421
+ | Motion | `ease-spring` (enter and press), `ease-standard`, `ease-in`, `ease-out`; `duration-instant`, `-fast`, `-normal`, `-slow` (0ms under reduced motion) |
422
+ | Sizes | `h-control-sm`, `-md`, `-lg` (and `w-`, `min-h-`, …), `size-target` (the 24px minimum pointer target), `max-w-xs` to `max-w-2xl` and `@xs:` to `@2xl:` container queries |
423
+ | Layers | `z-sticky`, `z-overlay`, `z-modal`, `z-popover`, `z-dropdown`, `z-toast`, `z-tooltip` |
424
+ | Dark mode | `dark:` follows `data-theme="dark"`, not the OS setting. |
425
+
426
+ Tailwind's numeric spacing (`p-4` = 1rem) already matches the 4px token scale, and the breakpoints (`sm:` to `2xl:`) are the same as Tailwind's.
427
+
428
+ Some Tailwind names change meaning with the preset: `rounded-*`, `shadow-*`, `blur-sm`/`-lg`, `ease-in`/`-out`, `font-mono`, `font-medium` to `font-black`, `leading-*`, and the `text-*` sizes take the library's values (for example, `rounded-md` is 12px and `font-black` is 800). So do the containers: `max-w-md` and `@md:` are 48rem, not Tailwind's 28rem. The library's stylesheet already gives some of these names its own values once it's loaded, even without the preset; the preset keeps the utilities and the container queries consistent.
429
+
430
+ For text contrast, use the pairs the components use: `text-text` or `text-text-muted` on `bg-bg`, `bg-surface`, and the other surfaces; `text-on-primary` on `bg-primary` (likewise `on-accent`, `on-success`, …); `text-primary-subtle-text` on `bg-primary-subtle` (likewise for each tone). These pairs meet WCAG 2.2 AA in both themes and every brand. Don't use accent or chart colors for text.
431
+
418
432
  The preset doesn't change the components, and Tailwind's preflight (its CSS reset) doesn't override them, whichever stylesheet loads first.
419
433
 
420
434
  # Guide: Languages
421
435
 
422
- Components have built-in text: button names like "Close" and "Next page", screen-reader announcements like "3 results available", validation messages, and date formats. Wrap your app in `LocaleProvider` to show all of it in another language:
423
-
424
- ```tsx
425
- import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
426
- import es from "@vjdesigns/vjdesigns-ui/locales/es";
427
-
428
- <LocaleProvider locale="es" messages={es}>
429
- <App />
430
- </LocaleProvider>
431
- ```
432
-
433
- `LocaleProvider` sets:
434
-
435
- - **Built-in text** for every component, from `messages`.
436
- - **Dates and numbers** in the locale's format (`23/10/2026`, `1.234,5`), and plurals that follow the language's rules.
437
- - **Writing direction**: Arabic, Hebrew, Persian, and Urdu get `dir="rtl"`, and layouts and arrow keys mirror.
438
- - **`lang`** on its wrapper, so screen readers pronounce the text correctly. Popups (menus, dialogs, tooltips) keep the language of the area that opened them.
439
-
440
- Each locale is a separate import, so your app only downloads the languages it uses. Without a `LocaleProvider`, components use English text and the browser's date and number format.
441
-
442
- This library only translates its own built-in text. Text your app passes in, like `<Button>Save</Button>`, is your app's content: translate it with your app's i18n library (react-i18next, FormatJS, and so on).
443
-
444
- ### What gets translated
445
-
446
- The language is never picked automatically from where the user lives or their browser settings. Your app chooses it by rendering a `LocaleProvider`. For example, with `<LocaleProvider locale="de" messages={de}>`:
447
-
448
- | | Translated? |
449
- | --- | --- |
450
- | Text your app passes in, like `<Button>Save</Button>` | No: your app translates it |
451
- | Built-in names, like "Close", "Next page", "Clear search" | Yes: "Schließen", "Nächste Seite", "Suche löschen" |
452
- | Screen-reader announcements, like "3 results available" | Yes: "3 Ergebnisse verfügbar" |
453
- | Validation messages, empty states, file-upload prompts | Yes |
454
- | Dates and numbers | Yes: "23.10.2026", "4,5" |
455
-
456
- To follow the user's browser language, pass it yourself: `locale={navigator.language}` together with the matching `messages` (see [Switching language at runtime](#switching-language-at-runtime)).
457
-
458
- ### Bundled languages
459
-
460
- `ar` Arabic · `bn` Bengali · `cs` Czech · `da` Danish · `de` German · `el` Greek · `es` Spanish · `fa` Persian · `fi` Finnish · `fr` French · `he` Hebrew · `hi` Hindi · `hu` Hungarian · `id` Indonesian · `it` Italian · `ja` Japanese · `ko` Korean · `nb` Norwegian Bokmål · `nl` Dutch · `pl` Polish · `pt-BR` Portuguese (Brazil) · `ro` Romanian · `ru` Russian · `sv` Swedish · `th` Thai · `tr` Turkish · `uk` Ukrainian · `ur` Urdu · `vi` Vietnamese · `zh-Hans` Chinese (Simplified) · `zh-Hant` Chinese (Traditional), plus English (the default).
461
-
462
- The translations are machine-generated and haven't been reviewed by native speakers yet. If you find a wrong or awkward phrase, override it (below) and report it so the bundled locale can be fixed. (Working on the library itself? See [Translating built-in text](#translating-built-in-text).)
463
-
464
- ### Changing a few strings
465
-
466
- Pass only the strings you want to change. Everything else falls back to the outer provider's language (English at the top):
467
-
468
- ```tsx
469
- <LocaleProvider locale="en-GB" messages={{ pagination: { next: "Onwards" } }}>
470
- ```
471
-
472
- Providers nest, so an inner provider can switch the language for one part of the page. Per-component props such as `clearLabel` or `labels` still win over the provider.
473
-
474
- ### Other languages
475
-
476
- For a language that isn't bundled, write a complete messages object. TypeScript flags any missing string. Use English as the template:
477
-
478
- ```ts
479
- import { en, plural, type Messages } from "@vjdesigns/vjdesigns-ui";
480
-
481
- const p = plural("sw");
482
- export const sw: Messages = {
483
- ...en,
484
- pagination: { ...en.pagination, next: "Ukurasa unaofuata", previous: "Ukurasa uliopita" },
485
- searchInput: {
486
- ...en.searchInput,
487
- results: (count) => p(count, { "=0": "Hakuna matokeo", one: "Tokeo #", other: "Matokeo #" }),
488
- },
489
- // ...
490
- };
491
- ```
492
-
493
- `plural(locale)` picks the right plural form for any language (`#` is the formatted number).
494
-
495
- ### Switching language at runtime
496
-
497
- List the languages your app offers as loaders, so each one is downloaded only when picked:
498
-
499
- ```tsx
500
- import { LocaleProvider, type Messages } from "@vjdesigns/vjdesigns-ui";
501
-
502
- const loaders: Record<string, () => Promise<{ default: Messages }>> = {
503
- es: () => import("@vjdesigns/vjdesigns-ui/locales/es"),
504
- fr: () => import("@vjdesigns/vjdesigns-ui/locales/fr"),
505
- ar: () => import("@vjdesigns/vjdesigns-ui/locales/ar"),
506
- };
507
-
508
- function App({ lang }: { lang: string }) {
509
- const [messages, setMessages] = useState<Messages>();
510
- useEffect(() => {
511
- const load = loaders[lang];
512
- if (load) load().then((mod) => setMessages(mod.default));
513
- else setMessages(undefined); // English
514
- }, [lang]);
515
- // Until a language loads, the previous one (or English) shows.
516
- return <LocaleProvider locale={lang} messages={messages}>…</LocaleProvider>;
517
- }
518
- ```
519
-
436
+ Components have built-in text: button names like "Close" and "Next page", screen-reader announcements like "3 results available", validation messages, and date formats. Wrap your app in `LocaleProvider` to show all of it in another language:
437
+
438
+ ```tsx
439
+ import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
440
+ import es from "@vjdesigns/vjdesigns-ui/locales/es";
441
+
442
+ <LocaleProvider locale="es" messages={es}>
443
+ <App />
444
+ </LocaleProvider>
445
+ ```
446
+
447
+ `LocaleProvider` sets:
448
+
449
+ - **Built-in text** for every component, from `messages`.
450
+ - **Dates and numbers** in the locale's format (`23/10/2026`, `1.234,5`), and plurals that follow the language's rules.
451
+ - **Writing direction**: Arabic, Hebrew, Persian, and Urdu get `dir="rtl"`, and layouts and arrow keys mirror.
452
+ - **`lang`** on its wrapper, so screen readers pronounce the text correctly. Popups (menus, dialogs, tooltips) keep the language of the area that opened them.
453
+
454
+ Each locale is a separate import, so your app only downloads the languages it uses. Without a `LocaleProvider`, components use English text and the browser's date and number format.
455
+
456
+ This library only translates its own built-in text. Text your app passes in, like `<Button>Save</Button>`, is your app's content: translate it with your app's i18n library (react-i18next, FormatJS, and so on).
457
+
458
+ ### What gets translated
459
+
460
+ The language is never picked automatically from where the user lives or their browser settings. Your app chooses it by rendering a `LocaleProvider`. For example, with `<LocaleProvider locale="de" messages={de}>`:
461
+
462
+ | | Translated? |
463
+ | --- | --- |
464
+ | Text your app passes in, like `<Button>Save</Button>` | No: your app translates it |
465
+ | Built-in names, like "Close", "Next page", "Clear search" | Yes: "Schließen", "Nächste Seite", "Suche löschen" |
466
+ | Screen-reader announcements, like "3 results available" | Yes: "3 Ergebnisse verfügbar" |
467
+ | Validation messages, empty states, file-upload prompts | Yes |
468
+ | Dates and numbers | Yes: "23.10.2026", "4,5" |
469
+
470
+ To follow the user's browser language, pass it yourself: `locale={navigator.language}` together with the matching `messages` (see [Switching language at runtime](#switching-language-at-runtime)).
471
+
472
+ ### Bundled languages
473
+
474
+ `ar` Arabic · `bn` Bengali · `cs` Czech · `da` Danish · `de` German · `el` Greek · `es` Spanish · `fa` Persian · `fi` Finnish · `fr` French · `he` Hebrew · `hi` Hindi · `hu` Hungarian · `id` Indonesian · `it` Italian · `ja` Japanese · `ko` Korean · `nb` Norwegian Bokmål · `nl` Dutch · `pl` Polish · `pt-BR` Portuguese (Brazil) · `ro` Romanian · `ru` Russian · `sv` Swedish · `th` Thai · `tr` Turkish · `uk` Ukrainian · `ur` Urdu · `vi` Vietnamese · `zh-Hans` Chinese (Simplified) · `zh-Hant` Chinese (Traditional), plus English (the default).
475
+
476
+ The translations are machine-generated and haven't been reviewed by native speakers yet. If you find a wrong or awkward phrase, override it (below) and report it so the bundled locale can be fixed. (Working on the library itself? See [Translating built-in text](#translating-built-in-text).)
477
+
478
+ ### Changing a few strings
479
+
480
+ Pass only the strings you want to change. Everything else falls back to the outer provider's language (English at the top):
481
+
482
+ ```tsx
483
+ <LocaleProvider locale="en-GB" messages={{ pagination: { next: "Onwards" } }}>
484
+ ```
485
+
486
+ Providers nest, so an inner provider can switch the language for one part of the page. Per-component props such as `clearLabel` or `labels` still win over the provider.
487
+
488
+ ### Other languages
489
+
490
+ For a language that isn't bundled, write a complete messages object. TypeScript flags any missing string. Use English as the template:
491
+
492
+ ```ts
493
+ import { en, plural, type Messages } from "@vjdesigns/vjdesigns-ui";
494
+
495
+ const p = plural("sw");
496
+ export const sw: Messages = {
497
+ ...en,
498
+ pagination: { ...en.pagination, next: "Ukurasa unaofuata", previous: "Ukurasa uliopita" },
499
+ searchInput: {
500
+ ...en.searchInput,
501
+ results: (count) => p(count, { "=0": "Hakuna matokeo", one: "Tokeo #", other: "Matokeo #" }),
502
+ },
503
+ // ...
504
+ };
505
+ ```
506
+
507
+ `plural(locale)` picks the right plural form for any language (`#` is the formatted number).
508
+
509
+ ### Switching language at runtime
510
+
511
+ List the languages your app offers as loaders, so each one is downloaded only when picked:
512
+
513
+ ```tsx
514
+ import { LocaleProvider, type Messages } from "@vjdesigns/vjdesigns-ui";
515
+
516
+ const loaders: Record<string, () => Promise<{ default: Messages }>> = {
517
+ es: () => import("@vjdesigns/vjdesigns-ui/locales/es"),
518
+ fr: () => import("@vjdesigns/vjdesigns-ui/locales/fr"),
519
+ ar: () => import("@vjdesigns/vjdesigns-ui/locales/ar"),
520
+ };
521
+
522
+ function App({ lang }: { lang: string }) {
523
+ const [messages, setMessages] = useState<Messages>();
524
+ useEffect(() => {
525
+ const load = loaders[lang];
526
+ if (load) load().then((mod) => setMessages(mod.default));
527
+ else setMessages(undefined); // English
528
+ }, [lang]);
529
+ // Until a language loads, the previous one (or English) shows.
530
+ return <LocaleProvider locale={lang} messages={messages}>…</LocaleProvider>;
531
+ }
532
+ ```
533
+
520
534
  For server rendering, also set `<html lang="…" dir="…">` on the page. `getLocaleDirection(locale)` returns `"ltr"` or `"rtl"`.
521
535
 
522
536
  # Guide: Form validation
523
537
 
524
- > **Front-end validation is not security.** It helps people fill in a form correctly, but anyone can turn off JavaScript or send requests straight to your server. Always validate again on the server. The format checks below (`isEmail`, `isIP`, …) are plain functions you can reuse there.
525
-
526
- `useFormValidation` checks a form when it's submitted, using the browser's own rules on each input (`required`, `type="email"`, `minLength`, `pattern`, `min` / `max`) plus any rules you add. Messages follow the current language.
527
-
528
- ```tsx
529
- import {
530
- useFormValidation, rules, ErrorSummary, Field, Input, PasswordInput, Button,
531
- } from "@vjdesigns/vjdesigns-ui";
532
-
533
- function SignUp() {
534
- const form = useFormValidation({
535
- rules: {
536
- confirm: rules.matches("password", "The passwords don't match."),
537
- serverIp: rules.ip(), // IPv4 or IPv6
538
- },
539
- // Runs only when everything is valid. Return the server's errors to show them on their fields.
540
- onValid: async (values) => {
541
- const response = await api.signUp(values);
542
- return response.errors; // e.g. { username: "That username is taken." }
543
- },
544
- });
545
-
546
- return (
547
- <form {...form.formProps}>
548
- <ErrorSummary ref={form.summaryRef} errors={form.errorList} />
549
- <Field label="Email" required error={form.errors.email}>
550
- <Input name="email" type="email" />
551
- </Field>
552
- <Field label="Password" required error={form.errors.password}>
553
- <PasswordInput name="password" minLength={12} />
554
- </Field>
555
- <Field label="Confirm password" required error={form.errors.confirm}>
556
- <PasswordInput name="confirm" />
557
- </Field>
558
- <Field label="Server IP" error={form.errors.serverIp}>
559
- <Input name="serverIp" />
560
- </Field>
561
- <Button type="submit" loading={form.isSubmitting}>Create account</Button>
562
- </form>
563
- );
564
- }
565
- ```
566
-
567
- How it behaves:
568
-
569
- - **On submit**, every field is checked. If anything is wrong, the `ErrorSummary` at the top lists the problems and takes focus, so screen readers announce it. Each item links to its field. Without a summary, focus goes to the first invalid field.
570
- - **Errors are keyed by the field's `name`.** Pass `form.errors.<name>` to each `Field`'s `error`.
571
- - **After a failed submit**, an error disappears as soon as the field is fixed (while typing), and a field is fully re-checked when you leave it. It doesn't nag while you're still typing.
572
- - **Server errors** (returned from `onValid`, or set with `form.setErrors({...})`) show on their fields and stay until that field is edited.
573
- - **Emails** must have a real domain (`name@example.com`). The browser's own check also accepts `name@localhost`.
574
-
575
- ### Rules and format checks
576
-
577
- | Rule | Checks |
578
- | --- | --- |
579
- | `rules.required()` | Not empty (for controls without a native `required`) |
580
- | `rules.email()` | An email address in the usual format, with a top-level domain |
581
- | `rules.ip()` / `rules.ip({ version: 4 })` / `rules.ip({ version: 6 })` | An IPv4 or IPv6 address |
582
- | `rules.minLength(n)` / `rules.maxLength(n)` | Length in characters |
583
- | `rules.pattern(/regex/, "message")` | The whole value matches |
584
- | `rules.matches("otherField")` | Equals another field (confirm password) |
585
- | your own `(value, { values }) => message` | Anything else |
586
-
587
- Each rule takes an optional custom message. The checks behind them are exported for use anywhere, including your server:
588
-
589
- - `isEmail(value)`
590
- - `isIPv4(value)`: four numbers 0–255, no leading zeros
591
- - `isIPv6(value)`: including `::` shorthand and IPv4 tails like `::ffff:192.168.0.1`
538
+ > **Front-end validation is not security.** It helps people fill in a form correctly, but anyone can turn off JavaScript or send requests straight to your server. Always validate again on the server. The format checks below (`isEmail`, `isIP`, …) are plain functions you can reuse there.
539
+
540
+ `useFormValidation` checks a form when it's submitted, using the browser's own rules on each input (`required`, `type="email"`, `minLength`, `pattern`, `min` / `max`) plus any rules you add. Messages follow the current language.
541
+
542
+ ```tsx
543
+ import {
544
+ useFormValidation, rules, ErrorSummary, Field, Input, PasswordInput, Button,
545
+ } from "@vjdesigns/vjdesigns-ui";
546
+
547
+ function SignUp() {
548
+ const form = useFormValidation({
549
+ rules: {
550
+ confirm: rules.matches("password", "The passwords don't match."),
551
+ serverIp: rules.ip(), // IPv4 or IPv6
552
+ },
553
+ // Runs only when everything is valid. Return the server's errors to show them on their fields.
554
+ onValid: async (values) => {
555
+ const response = await api.signUp(values);
556
+ return response.errors; // e.g. { username: "That username is taken." }
557
+ },
558
+ });
559
+
560
+ return (
561
+ <form {...form.formProps}>
562
+ <ErrorSummary ref={form.summaryRef} errors={form.errorList} />
563
+ <Field label="Email" required error={form.errors.email}>
564
+ <Input name="email" type="email" />
565
+ </Field>
566
+ <Field label="Password" required error={form.errors.password}>
567
+ <PasswordInput name="password" minLength={12} />
568
+ </Field>
569
+ <Field label="Confirm password" required error={form.errors.confirm}>
570
+ <PasswordInput name="confirm" />
571
+ </Field>
572
+ <Field label="Server IP" error={form.errors.serverIp}>
573
+ <Input name="serverIp" />
574
+ </Field>
575
+ <Button type="submit" loading={form.isSubmitting}>Create account</Button>
576
+ </form>
577
+ );
578
+ }
579
+ ```
580
+
581
+ How it behaves:
582
+
583
+ - **On submit**, every field is checked. If anything is wrong, the `ErrorSummary` at the top lists the problems and takes focus, so screen readers announce it. Each item links to its field. Without a summary, focus goes to the first invalid field.
584
+ - **Errors are keyed by the field's `name`.** Pass `form.errors.<name>` to each `Field`'s `error`.
585
+ - **After a failed submit**, an error disappears as soon as the field is fixed (while typing), and a field is fully re-checked when you leave it. It doesn't nag while you're still typing.
586
+ - **Server errors** (returned from `onValid`, or set with `form.setErrors({...})`) show on their fields and stay until that field is edited.
587
+ - **Emails** must have a real domain (`name@example.com`). The browser's own check also accepts `name@localhost`.
588
+
589
+ ### Rules and format checks
590
+
591
+ | Rule | Checks |
592
+ | --- | --- |
593
+ | `rules.required()` | Not empty (for controls without a native `required`) |
594
+ | `rules.email()` | An email address in the usual format, with a top-level domain |
595
+ | `rules.ip()` / `rules.ip({ version: 4 })` / `rules.ip({ version: 6 })` | An IPv4 or IPv6 address |
596
+ | `rules.minLength(n)` / `rules.maxLength(n)` | Length in characters |
597
+ | `rules.pattern(/regex/, "message")` | The whole value matches |
598
+ | `rules.matches("otherField")` | Equals another field (confirm password) |
599
+ | your own `(value, { values }) => message` | Anything else |
600
+
601
+ Each rule takes an optional custom message. The checks behind them are exported for use anywhere, including your server:
602
+
603
+ - `isEmail(value)`
604
+ - `isIPv4(value)`: four numbers 0–255, no leading zeros
605
+ - `isIPv6(value)`: including `::` shorthand and IPv4 tails like `::ffff:192.168.0.1`
592
606
  - `isIP(value, version?)`
593
607
 
594
608
  # Components
@@ -1019,24 +1033,24 @@ import { Chat } from "@vjdesigns/vjdesigns-ui";
1019
1033
 
1020
1034
  Category: data-display · Storybook: Data Display/Chat
1021
1035
 
1022
- A chat interface for an AI assistant (or a person), with no backend of its
1023
- own: `onSend` connects it to any API and can stream the reply. Includes a
1024
- scrolling conversation that follows new messages, an auto-growing message
1025
- box (Enter sends, Shift+Enter adds a line), Stop and Retry, copy buttons,
1026
- suggested prompts, and screen reader announcements of each reply.
1027
-
1028
- ```tsx
1029
- <Chat
1030
- style={{ blockSize: 560 }}
1031
- onSend={async function* (text, { messages, signal }) {
1032
- const res = await fetch("/api/chat", {
1033
- method: "POST",
1034
- body: JSON.stringify({ messages }),
1035
- signal,
1036
- });
1037
- yield* readTextStream(res);
1038
- }}
1039
- />
1036
+ A chat interface for an AI assistant (or a person), with no backend of its
1037
+ own: `onSend` connects it to any API and can stream the reply. Includes a
1038
+ scrolling conversation that follows new messages, an auto-growing message
1039
+ box (Enter sends, Shift+Enter adds a line), Stop and Retry, copy buttons,
1040
+ suggested prompts, and screen reader announcements of each reply.
1041
+
1042
+ ```tsx
1043
+ <Chat
1044
+ style={{ blockSize: 560 }}
1045
+ onSend={async function* (text, { messages, signal }) {
1046
+ const res = await fetch("/api/chat", {
1047
+ method: "POST",
1048
+ body: JSON.stringify({ messages }),
1049
+ signal,
1050
+ });
1051
+ yield* readTextStream(res);
1052
+ }}
1053
+ />
1040
1054
  ```
1041
1055
 
1042
1056
  ### Props
@@ -1052,7 +1066,7 @@ suggested prompts, and screen reader announcements of each reply.
1052
1066
  - `onDraftChange`: `(draft: string) => void`. Called with the message box text on every edit.
1053
1067
  - `suggestions`: `string[]`. Prompts offered as buttons while the conversation is empty. Pressing one sends it.
1054
1068
  - `emptyState`: `ReactNode`. Shown while the conversation is empty, above the suggestions. Defaults to a short greeting (`labels.emptyTitle`).
1055
- - `renderContent`: `(message: ChatMessage) => ReactNode`. Renders a message's content, e.g. through your Markdown renderer. Defaults to plain text with line breaks kept. Never render unsanitized HTML from a model or a user.
1069
+ - `renderContent`: `(message: ChatMessage) => ReactNode`. Renders a message's content, e.g. through your Markdown renderer. Defaults to plain text with line breaks kept, which is always safe. **Security:** treat every message as untrusted, including the model's replies (a prompt injection can make a model write anything). When you render it yourself: - Render to React elements, not an HTML string. Don't pass content to `dangerouslySetInnerHTML`, and don't enable raw HTML in your Markdown renderer. If you must render HTML, sanitize it first (e.g. DOMPurify). - Allow only `http:`, `https:`, and `mailto:` link URLs (no `javascript:` or `data:`), and give external links `rel="noopener noreferrer"`. - Don't load remote images from message content automatically: an image URL can leak data from the conversation to another server.
1056
1070
  - `assistantName`: `string`. Name of the assistant, read to screen readers ("Coach said:"). Defaults to `labels.assistant`.
1057
1071
  - `assistantAvatar`: `ReactNode`. Shown beside assistant messages (e.g. an `Avatar` or `Icon`). Decorative: hidden from assistive technology.
1058
1072
  - `userAvatar`: `ReactNode`. Shown beside user messages. Decorative: hidden from assistive technology.
@@ -1079,7 +1093,7 @@ suggested prompts, and screen reader announcements of each reply.
1079
1093
  - Disabled
1080
1094
  - With Max Length: `maxLength` limits a message and shows a counter near the limit.
1081
1095
  - System Messages: System messages (joins, handoffs, context notes) are centered notes.
1082
- - Custom Rendering: `renderContent` renders messages your way, e.g. through a Markdown renderer. This one turns `**bold**` into `<strong>` and keeps paragraphs. Never render unsanitized HTML from a model.
1096
+ - Custom Rendering: `renderContent` renders messages your way, e.g. through a Markdown renderer. This one turns `**bold**` into `<strong>` and keeps paragraphs, building React elements rather than an HTML string, so nothing in a message can run as code. Treat model replies as untrusted, like user input: never render them with `dangerouslySetInnerHTML` or a Markdown renderer's raw-HTML mode (sanitize with a library such as DOMPurify if you must), allow only `http:`, `https:`, and `mailto:` links, and don't auto-load remote images from replies, since an image URL can leak conversation data.
1083
1097
  - Controlled: Controlled: the parent owns the messages, so it can save, clear, or seed them. Here, `onSend` returns nothing and the parent adds the reply itself (the way a WebSocket or a human agent would).
1084
1098
  - Connecting ABackend: How to connect a real backend: stream server-sent events from your API route with `readEventStream`, passing `signal` so Stop cancels the request. ```tsx import { Chat, readEventStream } from "@vjdesigns/vjdesigns-ui"; <Chat onSend={async function* (_text, { messages, signal }) { const res = await fetch("/api/chat", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ messages: messages.map(({ role, content }) => ({ role, content })), }), signal, }); if (!res.ok) throw new Error(`Chat request failed: ${res.status}`); for await (const data of readEventStream(res)) { if (data === "[DONE]") break; yield JSON.parse(data).text ?? ""; } }} /> ``` Keep API keys on your server: the browser should call your own route, which calls the model provider. This story fakes the server with an in-memory event stream.
1085
1099
  - Right To Left: Right-to-left: user messages sit on the inline end, which is the left in RTL.
@@ -1258,6 +1272,67 @@ users can scroll it. Copy results are announced in a polite live region.
1258
1272
  - Custom highlighter
1259
1273
  - Both themes
1260
1274
 
1275
+ ## Collapsible
1276
+
1277
+ import { Collapsible } from "@vjdesigns/vjdesigns-ui";
1278
+
1279
+ Category: data-display · Storybook: Data Display/Collapsible
1280
+
1281
+ A show/hide section (WAI-ARIA disclosure). See `CollapsibleRoot`.
1282
+
1283
+ ### Props
1284
+
1285
+ - `open`: `boolean`. Controlled open state.
1286
+ - `defaultOpen`: `boolean` (default false). Initial open state when uncontrolled.
1287
+ - `onOpenChange`: `(open: boolean) => void`. Called with the next open state when the trigger is pressed (or find-in-page reveals the content).
1288
+ - `disabled`: `boolean` (default false). Disables the trigger, so the section stays in its current state.
1289
+ - `children`: `ReactNode`. A `Collapsible.Trigger` and a `Collapsible.Content`, anywhere inside.
1290
+ - Plus every native `<div>` attribute (className, style, id, aria-*, data-*, event handlers), spread onto the root.
1291
+
1292
+ ### Collapsible.Trigger
1293
+
1294
+ Also exported as `CollapsibleTrigger`.
1295
+
1296
+ The button that opens and closes the content. Renders a `Button`
1297
+ (`variant="ghost"`, `tone="neutral"` by default) with a turning chevron,
1298
+ or your own element with `asChild`.
1299
+
1300
+ - `variant`: `ButtonVariant` (default "solid"). Visual style. Inherits from a surrounding `ButtonGroup`.
1301
+ - `tone`: `Tone` (default "primary"). Semantic color. Inherits from a surrounding `ButtonGroup`.
1302
+ - `size`: `Size` (default "md"). Control height, padding, and type size. Inherits from a surrounding `ButtonGroup`.
1303
+ - `radius`: `Radius` (default "pill"). Corner rounding. When omitted, uses `--control-radius` (pill).
1304
+ - `disabled`: `boolean` (default false). Disables the control. Buttons use the native `disabled` attribute; links drop `href` and get `aria-disabled`.
1305
+ - `asChild`: `boolean` (default false). Render your own element instead of a `Button`, passing it the trigger's ARIA attributes, `onClick`, and `ref`. It must be a single element that renders a `<button>` (or a component that forwards these props to one).
1306
+ - `indicator`: `boolean` (default true). Show a chevron after the label that turns when open. Ignored with `asChild`.
1307
+ - `children`: `ReactNode`. The visible label, or your element with `asChild`.
1308
+ - Plus every native `<button>` attribute.
1309
+
1310
+ ### Collapsible.Content
1311
+
1312
+ Also exported as `CollapsibleContent`.
1313
+
1314
+ The content the trigger controls. Animates its height open and closed
1315
+ (instantly under `prefers-reduced-motion`), then gets the `hidden`
1316
+ attribute. Adds no padding, so it fits any layout.
1317
+
1318
+ - `forceMount`: `boolean` (default false). Keep the children mounted while closed (still hidden), e.g. to keep form state.
1319
+ - `hiddenUntilFound`: `boolean` (default false). Use `hidden="until-found"` where supported, so the browser's find-in-page can search the closed content and opens it on a match. Keeps the children mounted.
1320
+ - `children`: `ReactNode`. The content to show and hide.
1321
+ - Plus every native `<div>` attribute.
1322
+
1323
+ ### Examples (Storybook stories)
1324
+
1325
+ - Playground
1326
+ - Behavior: The trigger reports its state with `aria-expanded`; closed content is hidden.
1327
+ - Default Open
1328
+ - Disabled: A disabled collapsible keeps its state; the trigger can't be pressed.
1329
+ - Show More: The trigger and content can be anywhere inside the root: here a "Show all" button below a list.
1330
+ - Controlled: Controlled with `open` and `onOpenChange`, e.g. to open it from elsewhere.
1331
+ - Custom Trigger: `asChild` uses your own element as the trigger; it gets the ARIA wiring and click handling.
1332
+ - Hidden Until Found: `hiddenUntilFound` lets the browser's find-in-page (Ctrl+F) search the closed content and open it.
1333
+ - Long Content: Long content animates open and closed just the same.
1334
+ - Both Themes: Both themes side by side.
1335
+
1261
1336
  ## Countdown
1262
1337
 
1263
1338
  import { Countdown } from "@vjdesigns/vjdesigns-ui";
@@ -2214,6 +2289,7 @@ under `prefers-reduced-motion`).
2214
2289
  - `min`: `number`. Lower bound of the range.
2215
2290
  - `max`: `number`. Upper bound of the range.
2216
2291
  - `tone`: `Tone`. Semantic color of the fill. Color never carries meaning alone: pair `danger`/`warning` with a `label` and `showValue` (or `valueText`).
2292
+ - `toneSteps`: `readonly ProgressToneStep[]`. Change the fill color with the value. Bands are percentages of the range, checked in order; the first whose `upTo` is at or above the current percentage wins, and a step without `upTo` catches the rest. `tone` is used while indeterminate or when no step matches. Example: `[{ upTo: 40, tone: "danger" }, { upTo: 75, tone: "warning" }, { tone: "success" }]`. Color never carries meaning alone: also show the value or describe the state in `label` / `valueText`.
2217
2293
  - `label`: `ReactNode`. Visible label. Becomes the accessible name through `aria-labelledby`. Without it, pass `aria-label` (or `aria-labelledby`).
2218
2294
  - `showValue`: `boolean`. Show the formatted value (a percentage by default, see `formatValue`).
2219
2295
  - `formatValue`: `ProgressFormatValue`. Custom value formatter, e.g. `(v, max) => \`${v} of ${max} MB\``. Its result is shown with `showValue` and also used as `aria-valuetext`.
@@ -2287,6 +2363,7 @@ or an indeterminate sweep when `value` is not set. The root carries
2287
2363
  - `min`: `number`. Lower bound of the range.
2288
2364
  - `max`: `number`. Upper bound of the range.
2289
2365
  - `tone`: `Tone`. Semantic color of the fill. Color never carries meaning alone: pair `danger`/`warning` with a `label` and `showValue` (or `valueText`).
2366
+ - `toneSteps`: `readonly ProgressToneStep[]`. Change the fill color with the value. Bands are percentages of the range, checked in order; the first whose `upTo` is at or above the current percentage wins, and a step without `upTo` catches the rest. `tone` is used while indeterminate or when no step matches. Example: `[{ upTo: 40, tone: "danger" }, { upTo: 75, tone: "warning" }, { tone: "success" }]`. Color never carries meaning alone: also show the value or describe the state in `label` / `valueText`.
2290
2367
  - `label`: `ReactNode`. Visible label. Becomes the accessible name through `aria-labelledby`. Without it, pass `aria-label` (or `aria-labelledby`).
2291
2368
  - `showValue`: `boolean`. Show the formatted value (a percentage by default, see `formatValue`).
2292
2369
  - `formatValue`: `ProgressFormatValue`. Custom value formatter, e.g. `(v, max) => \`${v} of ${max} MB\``. Its result is shown with `showValue` and also used as `aria-valuetext`.
@@ -2305,6 +2382,7 @@ or an indeterminate sweep when `value` is not set. The root carries
2305
2382
  - Values
2306
2383
  - Indeterminate
2307
2384
  - Tones
2385
+ - Tone steps (color by value)
2308
2386
  - Sizes
2309
2387
  - Radii
2310
2388
  - With label and value
@@ -4494,7 +4572,7 @@ the first and last item; Space and Enter toggle the focused item.
4494
4572
  - `attached`: `boolean` (default false). Joins items edge to edge, sharing borders, with rounding on the outer corners only (like `ButtonGroup attached`).
4495
4573
  - `orientation`: `Orientation` (default "horizontal"). Layout direction. Also picks the arrow keys: Left/Right when horizontal, Up/Down when vertical.
4496
4574
  - `gap`: `Space` (default 2). Space between items (a `--space-*` step). Ignored when `attached`.
4497
- - `rovingFocus`: `boolean` (default true). Toolbar-style roving tabindex: the group is one Tab stop, and Arrow keys, Home, and End move focus between items (wrapping). Turn off to make every item its own Tab stop.
4575
+ - `rovingFocus`: `boolean` (default true (false inside a Toolbar)). Toolbar-style roving tabindex: the group is one Tab stop, and Arrow keys, Home, and End move focus between items (wrapping). Turn off to make every item its own Tab stop. Inside a `Toolbar` it defaults to off, so the items join the toolbar's own arrow keys.
4498
4576
  - `role`: `"group" | "toolbar"` (default "group"). ARIA role of the container. Use `"toolbar"` when the group is (or is the whole of) a formatting toolbar, such as Bold / Italic / Underline.
4499
4577
  - `required`: `boolean` (default false). Prevents unpressing the last pressed item: in `single` mode something is always selected; in `multiple` mode at least one item stays pressed.
4500
4578
  - `children`: `ReactNode`. `ToggleGroup.Item` elements. Group style props are passed down; an item's own props win (except `disabled`, which either can set).
@@ -6138,6 +6216,55 @@ focusable elements of its own.
6138
6216
  - Composition: settings page: A realistic composition: an account settings page with vertical tabs.
6139
6217
  - Custom ids and mounted panels: Tabs and panels wire up through the ids they actually render: custom ids on either side keep `aria-controls` / `aria-labelledby` valid, and a tab only points at a panel that is in the DOM (here the root keeps panels mounted, but "Stats" opts out).
6140
6218
 
6219
+ ## Toolbar
6220
+
6221
+ import { Toolbar } from "@vjdesigns/vjdesigns-ui";
6222
+
6223
+ Category: navigation · Storybook: Navigation/Toolbar
6224
+
6225
+ A row (or column) of controls that is one Tab stop, with arrow keys between controls.
6226
+
6227
+ ### Props
6228
+
6229
+ - `orientation`: `Orientation` (default "horizontal"). Direction of the controls. Also picks the arrow keys: Left/Right when horizontal (following the reading direction), Up/Down when vertical.
6230
+ - `variant`: `ToolbarVariant` (default "surface"). `surface`: a rounded, bordered bar. `plain`: no container styling.
6231
+ - `loop`: `boolean` (default true). Arrow keys wrap from the last control to the first, and back.
6232
+ - `wrap`: `boolean` (default false). Let controls wrap onto more lines when there isn't room (horizontal only).
6233
+ - `children`: `ReactNode`. The controls: buttons, toggle groups, links, menus, inputs, `Toolbar.Separator`, and `Toolbar.Group`.
6234
+ - Plus every native `<div>` attribute (className, style, id, aria-*, data-*, event handlers), spread onto the root.
6235
+
6236
+ ### Toolbar.Separator
6237
+
6238
+ Also exported as `ToolbarSeparator`.
6239
+
6240
+ A line between groups of controls, drawn across the toolbar's direction
6241
+ (`role="separator"`). It isn't focusable, and arrow keys skip it.
6242
+
6243
+ - `className`: `string`. Additional class for the separator.
6244
+
6245
+ ### Toolbar.Group
6246
+
6247
+ Also exported as `ToolbarGroup`.
6248
+
6249
+ Keeps related controls together (`role="group"`), so a wrapping toolbar
6250
+ moves them to the next line as one. Its controls stay in the toolbar's
6251
+ arrow-key order.
6252
+
6253
+ - `children`: `ReactNode`. Related controls. Name the group with `aria-label` (e.g. "Alignment") if the controls don't make it obvious.
6254
+ - Plus every native `<div>` attribute.
6255
+
6256
+ ### Examples (Storybook stories)
6257
+
6258
+ - Playground
6259
+ - Keyboard Navigation: One Tab stop; arrow keys, Home, and End move between every control, toggle groups included.
6260
+ - All Variants: `surface` draws a rounded bar; `plain` adds no container styling.
6261
+ - Vertical: Up and Down move between controls; the separator runs across.
6262
+ - Disabled And No Loop: Disabled controls are skipped by the arrow keys, and `loop={false}` stops at the ends.
6263
+ - With Input And Menu: A text field keeps its arrow keys, Home, and End for editing; Tab leaves the toolbar. A menu trigger is just another control.
6264
+ - With Composite Widget: Widgets with arrow keys of their own (here a `SegmentedControl`, a radio group) keep them, and stay a separate Tab stop.
6265
+ - Right To Left: In right-to-left layouts, Left and Right follow the reading direction.
6266
+ - Wrapping: With `wrap`, controls move to a new line when there isn't room; a `Toolbar.Group` wraps as one.
6267
+
6141
6268
  ## CommandPalette
6142
6269
 
6143
6270
  import { CommandPalette } from "@vjdesigns/vjdesigns-ui";
@@ -7023,6 +7150,54 @@ Groups related buttons (`role="group"`). Give it an `aria-label` or
7023
7150
  - `children`: `ReactNode`. The buttons. `size`, `variant`, `tone`, `radius`, and `disabled` are passed down; a button's own props win.
7024
7151
  - Plus every native `<div>` attribute (className, style, id, aria-*, data-*, event handlers), spread onto the root.
7025
7152
 
7153
+ ## CopyButton
7154
+
7155
+ import { CopyButton } from "@vjdesigns/vjdesigns-ui";
7156
+
7157
+ Category: primitives · Storybook: Primitives/CopyButton
7158
+
7159
+ A button that copies text to the clipboard and confirms it: the icon turns
7160
+ into a check and the label into "Copied", and the result is announced to
7161
+ screen readers through a polite live region (a label change on a focused
7162
+ button isn't reliably read). Falls back to a legacy copy method where the
7163
+ Clipboard API is blocked, and shows an error state if both fail.
7164
+
7165
+ Takes `Button`'s style props (`variant`, `tone`, `size`, `radius`) and any
7166
+ native `<button>` attribute. An `onClick` that calls `preventDefault()`
7167
+ cancels the copy.
7168
+
7169
+ ### Props
7170
+
7171
+ - `variant`: `ButtonVariant` (default "solid"). Visual style. Inherits from a surrounding `ButtonGroup`.
7172
+ - `tone`: `Tone` (default "primary"). Semantic color. Inherits from a surrounding `ButtonGroup`.
7173
+ - `size`: `Size` (default "md"). Control height, padding, and type size. Inherits from a surrounding `ButtonGroup`.
7174
+ - `radius`: `Radius` (default "pill"). Corner rounding. When omitted, uses `--control-radius` (pill).
7175
+ - `disabled`: `boolean` (default false). Disables the control. Buttons use the native `disabled` attribute; links drop `href` and get `aria-disabled`.
7176
+ - `value`: `string | (() => string)` (required). The text to copy, or a function that returns it when clicked (for values that change, such as the current URL).
7177
+ - `iconOnly`: `boolean` (default false). Show only the icon. The accessible name is `aria-label` if you pass one (e.g. "Copy invite link"), otherwise the translated "Copy".
7178
+ - `children`: `ReactNode` (default "Copy" (translated)). Visible label while idle.
7179
+ - `copiedLabel`: `string` (default "Copied" (translated)). Label shown and announced after a successful copy.
7180
+ - `copyErrorLabel`: `string` (default "Couldn't copy" (translated)). Label shown and announced when copying fails.
7181
+ - `timeout`: `number` (default 2000). How long the copied or error state shows, in milliseconds.
7182
+ - `onCopyStatusChange`: `(status: CopyStatus) => void`. Called with each copy result, then with `"idle"` when it resets.
7183
+ - Plus every native `<button>` attribute (className, style, id, aria-*, data-*, event handlers), spread onto the root.
7184
+
7185
+ ### Examples (Storybook stories)
7186
+
7187
+ - Playground
7188
+ - Behavior: Copying shows "Copied", announces it, reports the status, and resets after `timeout`.
7189
+ - Error State: When copying fails, the button says so (and announces it) instead of pretending it worked.
7190
+ - Icon Only: Icon only: the accessible name is `aria-label` (or "Copy"); the icon turns into a check.
7191
+ - Cancelable: An `onClick` that calls `preventDefault()` cancels the copy.
7192
+ - All Variants
7193
+ - All Tones
7194
+ - All Sizes
7195
+ - Disabled
7196
+ - In AField: Inside a read-only field, as the field's end element.
7197
+ - Computed Value: `value` can be a function, read when clicked, for values that change.
7198
+ - Custom Labels: Custom labels, for example in another language or for a specific action.
7199
+ - Both Themes: Both themes side by side.
7200
+
7026
7201
  ## Display
7027
7202
 
7028
7203
  import { Display } from "@vjdesigns/vjdesigns-ui";