@vjdesigns/vjdesigns-ui 3.7.0 → 3.8.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 (105) hide show
  1. package/CHANGELOG.md +204 -189
  2. package/README.md +854 -854
  3. package/dist/ai/llms-full.txt +784 -589
  4. package/dist/ai/llms.txt +4 -0
  5. package/dist/ai/registry.json +741 -17
  6. package/dist/components/data-display/Poll/Poll.cjs.js +1 -0
  7. package/dist/components/data-display/Poll/Poll.d.ts +114 -0
  8. package/dist/components/data-display/Poll/Poll.mjs +335 -0
  9. package/dist/components/data-display/Poll/Poll.module.css.cjs.js +1 -0
  10. package/dist/components/data-display/Poll/Poll.module.css.mjs +46 -0
  11. package/dist/components/data-display/Poll/index.d.ts +1 -0
  12. package/dist/components/data-display/RatingBreakdown/RatingBreakdown.cjs.js +1 -0
  13. package/dist/components/data-display/RatingBreakdown/RatingBreakdown.d.ts +35 -0
  14. package/dist/components/data-display/RatingBreakdown/RatingBreakdown.mjs +88 -0
  15. package/dist/components/data-display/RatingBreakdown/RatingBreakdown.module.css.cjs.js +1 -0
  16. package/dist/components/data-display/RatingBreakdown/RatingBreakdown.module.css.mjs +21 -0
  17. package/dist/components/data-display/RatingBreakdown/index.d.ts +1 -0
  18. package/dist/components/data-display/ReviewCard/ReviewCard.cjs.js +1 -0
  19. package/dist/components/data-display/ReviewCard/ReviewCard.d.ts +67 -0
  20. package/dist/components/data-display/ReviewCard/ReviewCard.mjs +174 -0
  21. package/dist/components/data-display/ReviewCard/ReviewCard.module.css.cjs.js +1 -0
  22. package/dist/components/data-display/ReviewCard/ReviewCard.module.css.mjs +26 -0
  23. package/dist/components/data-display/ReviewCard/index.d.ts +1 -0
  24. package/dist/components/forms/RatingScale/RatingScale.cjs.js +1 -0
  25. package/dist/components/forms/RatingScale/RatingScale.d.ts +106 -0
  26. package/dist/components/forms/RatingScale/RatingScale.mjs +175 -0
  27. package/dist/components/forms/RatingScale/RatingScale.module.css.cjs.js +1 -0
  28. package/dist/components/forms/RatingScale/RatingScale.module.css.mjs +28 -0
  29. package/dist/components/forms/RatingScale/index.d.ts +1 -0
  30. package/dist/components/navigation/MobileNav/MobileNav.module.css.cjs.js +1 -1
  31. package/dist/components/navigation/MobileNav/MobileNav.module.css.mjs +14 -14
  32. package/dist/components/primitives/Icon/icons.cjs.js +1 -1
  33. package/dist/components/primitives/Icon/icons.d.ts +70 -0
  34. package/dist/components/primitives/Icon/icons.mjs +203 -134
  35. package/dist/components/primitives/Typography/Typography.d.ts +2 -2
  36. package/dist/i18n/en.cjs.js +1 -1
  37. package/dist/i18n/en.mjs +161 -0
  38. package/dist/i18n/types.d.ts +171 -0
  39. package/dist/index.cjs.js +1 -1
  40. package/dist/index.d.ts +4 -0
  41. package/dist/index.mjs +111 -107
  42. package/dist/locales/ar.cjs.js +1 -1
  43. package/dist/locales/ar.mjs +196 -0
  44. package/dist/locales/bn.cjs.js +1 -1
  45. package/dist/locales/bn.mjs +131 -0
  46. package/dist/locales/cs.cjs.js +1 -1
  47. package/dist/locales/cs.mjs +181 -0
  48. package/dist/locales/da.cjs.js +1 -1
  49. package/dist/locales/da.mjs +161 -0
  50. package/dist/locales/de.cjs.js +1 -1
  51. package/dist/locales/de.mjs +161 -0
  52. package/dist/locales/el.cjs.js +1 -1
  53. package/dist/locales/el.mjs +161 -0
  54. package/dist/locales/es.cjs.js +1 -1
  55. package/dist/locales/es.mjs +161 -0
  56. package/dist/locales/fa.cjs.js +1 -1
  57. package/dist/locales/fa.mjs +131 -0
  58. package/dist/locales/fi.cjs.js +1 -1
  59. package/dist/locales/fi.mjs +161 -0
  60. package/dist/locales/fr.cjs.js +1 -1
  61. package/dist/locales/fr.mjs +166 -0
  62. package/dist/locales/he.cjs.js +1 -1
  63. package/dist/locales/he.mjs +171 -0
  64. package/dist/locales/hi.cjs.js +1 -1
  65. package/dist/locales/hi.mjs +161 -0
  66. package/dist/locales/hu.cjs.js +1 -1
  67. package/dist/locales/hu.mjs +131 -0
  68. package/dist/locales/id.cjs.js +1 -1
  69. package/dist/locales/id.mjs +131 -0
  70. package/dist/locales/it.cjs.js +1 -1
  71. package/dist/locales/it.mjs +166 -0
  72. package/dist/locales/ja.cjs.js +1 -1
  73. package/dist/locales/ja.mjs +131 -0
  74. package/dist/locales/ko.cjs.js +1 -1
  75. package/dist/locales/ko.mjs +131 -0
  76. package/dist/locales/nb.cjs.js +1 -1
  77. package/dist/locales/nb.mjs +161 -0
  78. package/dist/locales/nl.cjs.js +1 -1
  79. package/dist/locales/nl.mjs +161 -0
  80. package/dist/locales/pl.cjs.js +1 -1
  81. package/dist/locales/pl.mjs +181 -0
  82. package/dist/locales/pt-BR.cjs.js +1 -1
  83. package/dist/locales/pt-BR.mjs +166 -0
  84. package/dist/locales/ro.cjs.js +1 -1
  85. package/dist/locales/ro.mjs +171 -0
  86. package/dist/locales/ru.cjs.js +1 -1
  87. package/dist/locales/ru.mjs +181 -0
  88. package/dist/locales/sv.cjs.js +1 -1
  89. package/dist/locales/sv.mjs +161 -0
  90. package/dist/locales/th.cjs.js +1 -1
  91. package/dist/locales/th.mjs +131 -0
  92. package/dist/locales/tr.cjs.js +1 -1
  93. package/dist/locales/tr.mjs +131 -0
  94. package/dist/locales/uk.cjs.js +1 -1
  95. package/dist/locales/uk.mjs +181 -0
  96. package/dist/locales/ur.cjs.js +1 -1
  97. package/dist/locales/ur.mjs +161 -0
  98. package/dist/locales/vi.cjs.js +1 -1
  99. package/dist/locales/vi.mjs +131 -0
  100. package/dist/locales/zh-Hans.cjs.js +1 -1
  101. package/dist/locales/zh-Hans.mjs +131 -0
  102. package/dist/locales/zh-Hant.cjs.js +1 -1
  103. package/dist/locales/zh-Hant.mjs +131 -0
  104. package/dist/vjdesigns-ui.css +1 -1
  105. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- # @vjdesigns/vjdesigns-ui 3.7.0: full reference
1
+ # @vjdesigns/vjdesigns-ui 3.8.0: 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
 
@@ -12,597 +12,597 @@
12
12
 
13
13
  # Guide: Installation
14
14
 
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";
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";
64
64
  ```
65
65
 
66
66
  # Guide: Usage
67
67
 
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
-
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
+
324
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.
325
325
 
326
326
  # Guide: Theming
327
327
 
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
-
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
+
432
432
  The preset doesn't change the components, and Tailwind's preflight (its CSS reset) doesn't override them, whichever stylesheet loads first.
433
433
 
434
434
  # Guide: Languages
435
435
 
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
-
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
+
534
534
  For server rendering, also set `<html lang="…" dir="…">` on the page. `getLocaleDirection(locale)` returns `"ltr"` or `"rtl"`.
535
535
 
536
536
  # Guide: Form validation
537
537
 
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`
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`
606
606
  - `isIP(value, version?)`
607
607
 
608
608
  # Components
@@ -1740,6 +1740,142 @@ counted as an item.
1740
1740
  - Disabled
1741
1741
  - Both themes
1742
1742
 
1743
+ ## Poll
1744
+
1745
+ import { Poll } from "@vjdesigns/vjdesigns-ui";
1746
+
1747
+ Category: data-display · Storybook: Data Display/Poll
1748
+
1749
+ A poll with two phases: voting (a question with choices) and results
1750
+ (each choice's share, printed as a percentage, with bars). Four layouts:
1751
+ `bars`, `cards`, `compact`, and `versus` for two choices head to head.
1752
+ The poll is UI only: it reports votes through `onVote` and shows the
1753
+ counts you pass in `options`; storing votes and enforcing one vote per
1754
+ person is up to your server.
1755
+
1756
+ ### Props
1757
+
1758
+ - `question`: `ReactNode` (required). The question, rendered as a heading (see `headingLevel`).
1759
+ - `options`: `PollOption[]` (required). The choices, with their vote counts. Update `votes` after `onVote`, including the new vote.
1760
+ - `layout`: `PollLayout` (default "bars"). Layout of both phases. `versus` needs exactly two options.
1761
+ - `multiple`: `boolean` (default false). Allow more than one choice (checkboxes).
1762
+ - `maxChoices`: `number`. With `multiple`: the most choices one voter can pick.
1763
+ - `value`: `string[]`. The viewer's choice (controlled). After voting, it marks "Your vote" in the results.
1764
+ - `defaultValue`: `string[]` (default []). Initial choice (uncontrolled).
1765
+ - `onValueChange`: `(value: string[]) => void`. Called when the viewer's choice changes, before or as they vote.
1766
+ - `voted`: `boolean`. Whether the viewer has voted (controlled). Use with `onVotedChange`.
1767
+ - `defaultVoted`: `boolean` (default false). Initial voted state (uncontrolled), e.g. `true` when the server says they already voted.
1768
+ - `onVotedChange`: `(voted: boolean) => void`. Called when the voted state changes (after a vote, or on "Change vote").
1769
+ - `onVote`: `(values: string[]) => void | Promise<void>`. Called with the chosen values when the viewer votes. Return a promise to show a loading state; if it rejects, the poll stays in the voting phase (show your own error message).
1770
+ - `submitMode`: `PollSubmitMode` (default "instant" for a single choice, "button" with `multiple). `button`: choose, then press Vote. `instant`: clicking a choice votes (single choice only; each choice is a button).
1771
+ - `showResults`: `PollShowResults` (default "after-vote"). When results show: `after-vote`, `always` (results only, no voting), or `never` (only once the poll is closed, which avoids bandwagon voting).
1772
+ - `closed`: `boolean` (default false). The poll is over: voting is off and the final results show. Also true once `endsAt` passes.
1773
+ - `endsAt`: `string`. When voting ends: an ISO date ("2026-12-01", the end of that day) or date-time. Shown as "Ends in 3 days".
1774
+ - `totalVotes`: `number`. Total votes, when it differs from the sum of `votes` (e.g. multiple choice counts voters).
1775
+ - `allowChangeVote`: `boolean` (default false). Show a "Change vote" button in the results while the poll is open.
1776
+ - `highlightWinner`: `boolean` (default true). Mark the sole leader with a "Leading" (or "Winner") tag and bold label.
1777
+ - `headingLevel`: `2 | 3 | 4 | 5 | 6` (default 3). Heading level of the question.
1778
+ - `size`: `Size` (default "md"). Text and control size.
1779
+ - `labels`: `Partial<{ vote: string; changeVote: string; yourVote: string; leading: string; winner: string; finalResults: string; versus: string; }>`. Overrides the built-in text (vote button, tags, footer, announcements). Localize it here.
1780
+ - Plus every native `<div>` attribute (className, style, id, aria-*, data-*, event handlers), spread onto the root.
1781
+
1782
+ ### Examples (Storybook stories)
1783
+
1784
+ - Playground
1785
+ - Bars
1786
+ - Cards
1787
+ - Compact
1788
+ - Versus
1789
+ - All Layouts
1790
+ - Sizes
1791
+ - Multiple Choice
1792
+ - Async vote (loading and failure)
1793
+ - Hidden Until Closed
1794
+ - Closed
1795
+ - Ended By Date
1796
+ - Tie
1797
+ - No Votes Yet
1798
+ - Long Content
1799
+ - computePollResults()
1800
+
1801
+ ## RatingBreakdown
1802
+
1803
+ import { RatingBreakdown } from "@vjdesigns/vjdesigns-ui";
1804
+
1805
+ Category: data-display · Storybook: Data Display/RatingBreakdown
1806
+
1807
+ The summary above a review list: the average rating as a big number with
1808
+ stars, the review count, and one bar per level showing its share. Each
1809
+ row reads "5 stars: 920 reviews, 72%"; with `onLevelSelect` the rows are
1810
+ toggle buttons for filtering by level.
1811
+
1812
+ ### Props
1813
+
1814
+ - `counts`: `Record<number, number>` (required). Reviews per level, e.g. `{ 5: 920, 4: 210, 3: 80, 2: 40, 1: 34 }`. Missing levels count as 0.
1815
+ - `average`: `number`. The average rating. Computed from `counts` when omitted.
1816
+ - `total`: `number`. Total reviews. The sum of `counts` when omitted.
1817
+ - `max`: `number` (default 5). The highest level (number of stars).
1818
+ - `onLevelSelect`: `(level: number | null) => void`. Called when a level row is pressed, with that level, or `null` when the pressed row is pressed again. Turns each row into a toggle button for filtering a review list.
1819
+ - `selectedLevel`: `number | null`. The level currently filtered on (shown pressed). Use with `onLevelSelect`.
1820
+ - `recommendPercent`: `number`. Share of reviewers who would recommend, 0 to 100. Shown as "92% would recommend".
1821
+ - `layout`: `RatingBreakdownLayout` (default "stacked"). `stacked`: the average above the bars. `inline`: beside them (wraps on narrow screens).
1822
+ - `size`: `Size` (default "md"). Text size.
1823
+ - Plus every native `<div>` attribute (className, style, id, aria-*, data-*, event handlers), spread onto the root.
1824
+
1825
+ ### Examples (Storybook stories)
1826
+
1827
+ - Playground
1828
+ - Stacked
1829
+ - Inline
1830
+ - Filterable
1831
+ - Sizes
1832
+ - No Reviews
1833
+ - Ten Point Scale
1834
+
1835
+ ## ReviewCard
1836
+
1837
+ import { ReviewCard } from "@vjdesigns/vjdesigns-ui";
1838
+
1839
+ Category: data-display · Storybook: Data Display/ReviewCard
1840
+
1841
+ One customer review: the reviewer with avatar, star rating, date,
1842
+ verified badge, headline, body (clamped with "Read more"), a would-
1843
+ recommend indicator, photos, helpful votes, and an owner reply. Rendered
1844
+ as an `<article>` named by its headline (or the reviewer).
1845
+
1846
+ ### Props
1847
+
1848
+ - `author`: `ReviewAuthor` (required). The reviewer.
1849
+ - `rating`: `number`. Star rating, shown with `RatingDisplay`. Omit for a text-only review.
1850
+ - `max`: `number` (default 5). Highest rating.
1851
+ - `title`: `ReactNode`. Review headline, rendered as a heading (see `headingLevel`).
1852
+ - `headingLevel`: `2 | 3 | 4 | 5 | 6` (default 3). Heading level of `title`.
1853
+ - `date`: `string`. ISO date ("YYYY-MM-DD") the review was written. Formatted for the locale in a `<time>`.
1854
+ - `verified`: `boolean` (default false). Show a "Verified purchase" badge.
1855
+ - `verifiedLabel`: `string` (default "Verified purchase"). Text of the verified badge, e.g. "Verified attendee".
1856
+ - `recommend`: `boolean`. `true`: thumbs up "Recommends". `false`: thumbs down "Doesn't recommend". Omit to show neither.
1857
+ - `children`: `ReactNode`. The review body. Long text is clamped to `maxLines` with a "Read more" button.
1858
+ - `maxLines`: `number` (default 5). Lines shown before "Read more". `0` never clamps.
1859
+ - `media`: `ReactNode`. Photos or other media, shown under the body.
1860
+ - `helpfulCount`: `number`. How many people found the review helpful. Shown as "12 people found this helpful".
1861
+ - `helpful`: `boolean | null`. The viewer's helpful vote (controlled): `true` yes, `false` no, `null` none.
1862
+ - `defaultHelpful`: `boolean | null` (default null). Initial helpful vote (uncontrolled).
1863
+ - `onHelpfulChange`: `(helpful: boolean | null) => void`. Called with the viewer's helpful vote. Setting it shows "Helpful? Yes / No" toggle buttons; pressing the pressed one again clears it (`null`).
1864
+ - `response`: `ReviewResponse`. An owner or seller reply, shown indented under the review.
1865
+ - `actions`: `ReactNode`. Extra actions in the footer, e.g. Report or Share buttons.
1866
+ - Plus every native `<article>` attribute (className, style, id, aria-*, data-*, event handlers), spread onto the root.
1867
+
1868
+ ### Examples (Storybook stories)
1869
+
1870
+ - Playground
1871
+ - Complete
1872
+ - Long Review Read More
1873
+ - Short Review No Clamp
1874
+ - Does Not Recommend
1875
+ - Text Only
1876
+ - With Photos
1877
+ - Composition: reviews page
1878
+
1743
1879
  ## Stat
1744
1880
 
1745
1881
  import { Stat } from "@vjdesigns/vjdesigns-ui";
@@ -3985,6 +4121,65 @@ Not focusable. For an editable rating use `Rating`.
3985
4121
  - Rate This Game (Form)
3986
4122
  - Unrated (read-only and zero): A read-only rating with no value says "Not rated" (not "Rated 0"), and a value of 0 means unrated, not one star.
3987
4123
 
4124
+ ## RatingScale
4125
+
4126
+ import { RatingScale } from "@vjdesigns/vjdesigns-ui";
4127
+
4128
+ Category: forms · Storybook: Forms/RatingScale
4129
+
4130
+ A labeled, single-choice rating scale: faces, numbers (such as a 0 to 10
4131
+ likelihood scale), or thumbs up and down. Unlike `Rating`, each option is
4132
+ its own choice with its own name, so choosing one never fills the others.
4133
+ Built on native radios in a `role="radiogroup"`: Tab lands on the selected
4134
+ option, arrow keys move and select, and the value submits with a form.
4135
+
4136
+ ### Props
4137
+
4138
+ - `variant`: `RatingScaleVariant` (default "numbers"). Look and built-in options: five `faces` (very unhappy to very happy), `numbers` from `min` to `max` (e.g. a 0 to 10 likelihood scale), or `thumbs` up (`1`) and down (`0`).
4139
+ - `value`: `number | null`. Selected value (controlled). `null` means nothing is selected. Use with `onValueChange`.
4140
+ - `defaultValue`: `number | null` (default null). Initial value (uncontrolled).
4141
+ - `onValueChange`: `(value: number | null) => void`. Called with the selected value, or `null` when cleared.
4142
+ - `min`: `number` (default 1). `numbers` only: the lowest value.
4143
+ - `max`: `number` (default 5). `numbers` only: the highest value.
4144
+ - `options`: `RatingScaleOption[]`. Custom options, replacing the variant's built-in set (and `min` / `max`). The variant still sets the look.
4145
+ - `startLabel`: `ReactNode`. Caption under the first option, e.g. "Not likely". Also read as part of the description.
4146
+ - `endLabel`: `ReactNode`. Caption under the last option, e.g. "Very likely". Also read as part of the description.
4147
+ - `showLabels`: `boolean` (default false). Show each option's label under it (faces and thumbs).
4148
+ - `sentiment`: `boolean` (default false). `faces` only: tint the faces from danger (lowest) to success (highest). The face shapes already carry the meaning; the tint is extra.
4149
+ - `size`: `Size` (default "md"). Option size. Falls back to a surrounding Field's size.
4150
+ - `allowClear`: `boolean`. Let the user remove their choice: clicking (or pressing Space on) the selected option again, or pressing Delete / Backspace, resets it to `null`.
4151
+ - `clearHint`: `string` (default "Press Space on the selected rating, or Delete, to clear it."). Instructions announced with each option when `allowClear` is on. Localize it here.
4152
+ - `disabled`: `boolean`. Disables every option. Falls back to a surrounding Field's state.
4153
+ - `readOnly`: `boolean`. Show the value without allowing changes: a single `role="img"` named "Rated: Happy", plus a hidden input so the value still submits when `name` is set.
4154
+ - `invalid`: `boolean`. Marks the scale invalid: danger outlines and `aria-invalid`. Falls back to a surrounding Field's state.
4155
+ - `required`: `boolean`. A choice is required: sets native `required` on the radios. Falls back to a surrounding Field's state.
4156
+ - `name`: `string`. Shared `name` for the native radios (used in form submission). Generated with `useId` when omitted.
4157
+ - `getReadOnlyLabel`: `(option: RatingScaleOption) => string` (default "Rated: Happy"). Read-only: accessible name. Localize it here.
4158
+ - `unratedLabel`: `string` (default "Not rated"). Read-only with no value: accessible name.
4159
+ - `label`: `ReactNode`. Visible label, used when the scale stands alone. Ignored inside a `Field`/`Fieldset`, whose label or legend names it. Without a label, pass `aria-label` or `aria-labelledby`.
4160
+ - `description`: `ReactNode`. Help text under the label, linked with `aria-describedby`.
4161
+ - Plus every native `<div>` attribute (className, style, id, aria-*, data-*, event handlers), spread onto the root.
4162
+
4163
+ ### Examples (Storybook stories)
4164
+
4165
+ - Playground
4166
+ - Faces
4167
+ - Faces With Sentiment
4168
+ - Numbers (0 to 10)
4169
+ - One To Five
4170
+ - Thumbs
4171
+ - All Variants
4172
+ - Sizes
4173
+ - Allow Clear
4174
+ - Read Only
4175
+ - Read Only Unrated
4176
+ - Disabled
4177
+ - Invalid
4178
+ - Custom Options
4179
+ - In Field
4180
+ - Controlled
4181
+ - Survey Form
4182
+
3988
4183
  ## SearchForm
3989
4184
 
3990
4185
  import { SearchForm } from "@vjdesigns/vjdesigns-ui";
@@ -5678,15 +5873,15 @@ import { MobileNav } from "@vjdesigns/vjdesigns-ui";
5678
5873
 
5679
5874
  Category: navigation · Storybook: Navigation/MobileNav
5680
5875
 
5681
- A mobile navigation bar: a bottom tab bar, a top bar, or a side rail of
5682
- icon-and-label links. A bubble slides to the current item, with an
5683
- animated `effect` (floating bubbles by default; also sparkle, confetti,
5684
- glow, jelly, orbit, splash, or none). With reduced motion, the bubble simply
5685
- moves without the effects.
5686
-
5687
- Renders a `<nav>` landmark with a list of links. The current item has
5688
- `aria-current="page"` and is marked by the bubble's shape and an indicator
5689
- bar, never by color alone. Every item keeps its label as its accessible
5876
+ A mobile navigation bar: a bottom tab bar, a top bar, or a side rail of
5877
+ icon-and-label links. A bubble slides to the current item, with an
5878
+ animated `effect` (floating bubbles by default; also sparkle, confetti,
5879
+ glow, jelly, orbit, splash, or none). With reduced motion, the bubble simply
5880
+ moves without the effects.
5881
+
5882
+ Renders a `<nav>` landmark with a list of links. The current item has
5883
+ `aria-current="page"` and is marked by the bubble's shape and an indicator
5884
+ bar, never by color alone. Every item keeps its label as its accessible
5690
5885
  name, even when labels are hidden.
5691
5886
 
5692
5887
  ### Props
@@ -5713,9 +5908,9 @@ name, even when labels are hidden.
5713
5908
 
5714
5909
  Also exported as `MobileNavItem`.
5715
5910
 
5716
- One destination in a `MobileNav`: an icon over a label, in its own `<li>`.
5717
- Selecting it makes it current when the root is uncontrolled (and calls
5718
- `onValueChange`), even if a client-side router prevents the default
5911
+ One destination in a `MobileNav`: an icon over a label, in its own `<li>`.
5912
+ Selecting it makes it current when the root is uncontrolled (and calls
5913
+ `onValueChange`), even if a client-side router prevents the default
5719
5914
  navigation.
5720
5915
 
5721
5916
  - `as`: `C` (default "a"). The element or component to render, e.g. your router's `Link`. Use a link for navigation; `"button"` suits an action such as opening a sheet.
@@ -7608,7 +7803,7 @@ Hides content visually while keeping it available to screen readers.
7608
7803
 
7609
7804
  ## Icons
7610
7805
 
7611
- Decorative or labelled SVG icons, all with the same props as `Icon`: CheckIcon, CloseIcon, PlusIcon, MinusIcon, ChevronUpIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ArrowUpIcon, ArrowDownIcon, ArrowLeftIcon, ArrowRightIcon, ChevronsLeftIcon, ChevronsRightIcon, SearchIcon, MenuIcon, MoreHorizontalIcon, MoreVerticalIcon, InfoIcon, WarningIcon, ErrorIcon, SuccessIcon, HelpIcon, NoteIcon, OfflineIcon, EyeIcon, EyeOffIcon, CalendarIcon, ClockIcon, UploadIcon, DownloadIcon, TrashIcon, EditIcon, CopyIcon, ExternalLinkIcon, LinkIcon, HomeIcon, UserIcon, UsersIcon, SettingsIcon, BellIcon, StarIcon, StarFilledIcon, HeartIcon, HeartFilledIcon, FilterIcon, SortIcon, RefreshIcon, PauseIcon, PlayIcon, EyeDropperIcon, GripIcon, SunIcon, MoonIcon, LockIcon, MailIcon, FileIcon, FolderIcon, FolderOpenIcon, ImageIcon, LoaderIcon.
7806
+ Decorative or labelled SVG icons, all with the same props as `Icon`: CheckIcon, CloseIcon, PlusIcon, MinusIcon, ChevronUpIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ArrowUpIcon, ArrowDownIcon, ArrowLeftIcon, ArrowRightIcon, ChevronsLeftIcon, ChevronsRightIcon, SearchIcon, MenuIcon, MoreHorizontalIcon, MoreVerticalIcon, InfoIcon, WarningIcon, ErrorIcon, SuccessIcon, HelpIcon, NoteIcon, OfflineIcon, EyeIcon, EyeOffIcon, CalendarIcon, ClockIcon, UploadIcon, DownloadIcon, TrashIcon, EditIcon, CopyIcon, ExternalLinkIcon, LinkIcon, HomeIcon, UserIcon, UsersIcon, SettingsIcon, BellIcon, StarIcon, StarFilledIcon, HeartIcon, HeartFilledIcon, FilterIcon, SortIcon, RefreshIcon, PauseIcon, PlayIcon, EyeDropperIcon, GripIcon, SunIcon, MoonIcon, LockIcon, MailIcon, FileIcon, FolderIcon, FolderOpenIcon, ImageIcon, LoaderIcon, FaceVerySadIcon, FaceSadIcon, FaceNeutralIcon, FaceHappyIcon, FaceVeryHappyIcon, ThumbsUpIcon, ThumbsDownIcon, VerifiedIcon, VolumeIcon, VolumeOffIcon, FullscreenIcon, FullscreenExitIcon, CaptionsIcon, PipIcon.
7612
7807
 
7613
7808
  # Hooks
7614
7809