@vjdesigns/vjdesigns-ui 3.5.1 → 3.7.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 (81) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +854 -854
  3. package/dist/ai/llms-full.txt +647 -576
  4. package/dist/ai/llms.txt +1 -0
  5. package/dist/ai/registry.json +238 -6
  6. package/dist/components/navigation/MobileNav/MobileNav.cjs.js +1 -0
  7. package/dist/components/navigation/MobileNav/MobileNav.d.ts +170 -0
  8. package/dist/components/navigation/MobileNav/MobileNav.mjs +174 -0
  9. package/dist/components/navigation/MobileNav/MobileNav.module.css.cjs.js +1 -0
  10. package/dist/components/navigation/MobileNav/MobileNav.module.css.mjs +46 -0
  11. package/dist/components/navigation/MobileNav/index.d.ts +1 -0
  12. package/dist/i18n/en.cjs.js +1 -1
  13. package/dist/i18n/en.mjs +2 -0
  14. package/dist/i18n/types.d.ts +10 -0
  15. package/dist/index.cjs.js +1 -1
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.mjs +37 -36
  18. package/dist/locales/ar.cjs.js +1 -1
  19. package/dist/locales/ar.mjs +2 -0
  20. package/dist/locales/bn.cjs.js +1 -1
  21. package/dist/locales/bn.mjs +2 -0
  22. package/dist/locales/cs.cjs.js +1 -1
  23. package/dist/locales/cs.mjs +2 -0
  24. package/dist/locales/da.cjs.js +1 -1
  25. package/dist/locales/da.mjs +2 -0
  26. package/dist/locales/de.cjs.js +1 -1
  27. package/dist/locales/de.mjs +2 -0
  28. package/dist/locales/el.cjs.js +1 -1
  29. package/dist/locales/el.mjs +2 -0
  30. package/dist/locales/es.cjs.js +1 -1
  31. package/dist/locales/es.mjs +2 -0
  32. package/dist/locales/fa.cjs.js +1 -1
  33. package/dist/locales/fa.mjs +2 -0
  34. package/dist/locales/fi.cjs.js +1 -1
  35. package/dist/locales/fi.mjs +2 -0
  36. package/dist/locales/fr.cjs.js +1 -1
  37. package/dist/locales/fr.mjs +2 -0
  38. package/dist/locales/he.cjs.js +1 -1
  39. package/dist/locales/he.mjs +2 -0
  40. package/dist/locales/hi.cjs.js +1 -1
  41. package/dist/locales/hi.mjs +2 -0
  42. package/dist/locales/hu.cjs.js +1 -1
  43. package/dist/locales/hu.mjs +2 -0
  44. package/dist/locales/id.cjs.js +1 -1
  45. package/dist/locales/id.mjs +2 -0
  46. package/dist/locales/it.cjs.js +1 -1
  47. package/dist/locales/it.mjs +2 -0
  48. package/dist/locales/ja.cjs.js +1 -1
  49. package/dist/locales/ja.mjs +2 -0
  50. package/dist/locales/ko.cjs.js +1 -1
  51. package/dist/locales/ko.mjs +2 -0
  52. package/dist/locales/nb.cjs.js +1 -1
  53. package/dist/locales/nb.mjs +2 -0
  54. package/dist/locales/nl.cjs.js +1 -1
  55. package/dist/locales/nl.mjs +2 -0
  56. package/dist/locales/pl.cjs.js +1 -1
  57. package/dist/locales/pl.mjs +2 -0
  58. package/dist/locales/pt-BR.cjs.js +1 -1
  59. package/dist/locales/pt-BR.mjs +2 -0
  60. package/dist/locales/ro.cjs.js +1 -1
  61. package/dist/locales/ro.mjs +2 -0
  62. package/dist/locales/ru.cjs.js +1 -1
  63. package/dist/locales/ru.mjs +2 -0
  64. package/dist/locales/sv.cjs.js +1 -1
  65. package/dist/locales/sv.mjs +2 -0
  66. package/dist/locales/th.cjs.js +1 -1
  67. package/dist/locales/th.mjs +2 -0
  68. package/dist/locales/tr.cjs.js +1 -1
  69. package/dist/locales/tr.mjs +2 -0
  70. package/dist/locales/uk.cjs.js +1 -1
  71. package/dist/locales/uk.mjs +2 -0
  72. package/dist/locales/ur.cjs.js +1 -1
  73. package/dist/locales/ur.mjs +2 -0
  74. package/dist/locales/vi.cjs.js +1 -1
  75. package/dist/locales/vi.mjs +2 -0
  76. package/dist/locales/zh-Hans.cjs.js +1 -1
  77. package/dist/locales/zh-Hans.mjs +2 -0
  78. package/dist/locales/zh-Hant.cjs.js +1 -1
  79. package/dist/locales/zh-Hant.mjs +2 -0
  80. package/dist/vjdesigns-ui.css +1 -1
  81. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- # @vjdesigns/vjdesigns-ui 3.5.1: full reference
1
+ # @vjdesigns/vjdesigns-ui 3.7.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
@@ -5672,6 +5672,77 @@ mounted only while open.
5672
5672
  - Open Light: Open on load in the light theme. Hidden from the docs page because it takes focus.
5673
5673
  - Open Dark: Open on load in the dark theme. Hidden from the docs page because it takes focus.
5674
5674
 
5675
+ ## MobileNav
5676
+
5677
+ import { MobileNav } from "@vjdesigns/vjdesigns-ui";
5678
+
5679
+ Category: navigation · Storybook: Navigation/MobileNav
5680
+
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
5690
+ name, even when labels are hidden.
5691
+
5692
+ ### Props
5693
+
5694
+ - `children`: `ReactNode`. `MobileNav.Item`s, usually three to five.
5695
+ - `placement`: `MobileNavPlacement` (default "bottom"). Edge of the screen the bar sits on: `bottom`, `top`, or a `side` rail.
5696
+ - `side`: `MobileNavSide` (default "start"). With `placement="side"`, the edge the rail sits on (logical, so it mirrors in RTL).
5697
+ - `variant`: `MobileNavVariant` (default "surface"). Visual style. See `MobileNavVariant`.
5698
+ - `floating`: `boolean` (default false). Detaches the bar from the edge as a rounded, shadowed island with space around it.
5699
+ - `position`: `MobileNavPosition` (default "fixed"). `fixed` stays on its edge of the viewport; `sticky` sticks to its edge of the scroll container; `static` stays in the flow.
5700
+ - `size`: `Size` (default "md"). Bar height (or rail width) and icon size. Bars: sm 56px, md 64px, lg 72px. Rails: sm 64px, md 80px, lg 96px.
5701
+ - `effect`: `MobileNavEffect` (default "bubbles"). The animated effect when the current item changes: `bubbles`, `sparkle`, `confetti`, `glow`, `jelly`, `orbit`, `splash`, or `none` to turn it off. See `MobileNavEffect`.
5702
+ - `activeTone`: `MobileNavActiveTone` (default "accent"). Color of the bubble and indicator behind the current item.
5703
+ - `labels`: `MobileNavLabels` (default "always"). Which labels are visible: `always`, only the `active` item's, or `never`. Labels are always the items' accessible names.
5704
+ - `hideAbove`: `MobileNavBreakpoint`. Hides the bar at this breakpoint and wider, e.g. `"md"` to show it only on phones.
5705
+ - `reserveSpace`: `boolean` (default true). With `position="fixed"`, keeps focused and scrolled-to content clear of the bar (WCAG 2.4.11): while mounted, sets the matching `scroll-padding` on `<html>` to the space the bar covers, and `--mobile-nav-offset` on `<html>` to the same length, so the page can reserve room for it (`body { padding-block-end: var(--mobile-nav-offset, 0px) }` under a bottom bar). Both are restored on unmount, and are 0 while hidden by `hideAbove`.
5706
+ - `value`: `string`. The current item's `value`, when controlled. An item's own `active` prop wins.
5707
+ - `defaultValue`: `string`. The initially current item's `value`, when uncontrolled. Selecting an item makes it current.
5708
+ - `onValueChange`: `(value: string) => void`. Called with an item's `value` when it's selected.
5709
+ - `aria-label`: `string` (default "Main" (translated)). Accessible name of the navigation landmark.
5710
+ - Plus every native `<nav>` attribute (className, style, id, aria-*, data-*, event handlers), spread onto the root.
5711
+
5712
+ ### MobileNav.Item
5713
+
5714
+ Also exported as `MobileNavItem`.
5715
+
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
5719
+ navigation.
5720
+
5721
+ - `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.
5722
+ - `value`: `string`. Identifies the item for the root's `value` / `defaultValue` / `onValueChange`.
5723
+ - `active`: `boolean`. Marks the item as the current page (`aria-current="page"`), whatever the root's `value`. Use it when your router knows the current page.
5724
+ - `icon`: `ReactNode` (required). The icon. Decorative: the label names the item.
5725
+ - `activeIcon`: `ReactNode`. A different icon for the current item, e.g. a filled version, as an extra cue besides color.
5726
+ - `badge`: `MobileNavBadgeValue`. A count (shown with `Badge` `count`, capped at 99+, hidden at 0) or a short text such as "New", on the icon's corner. It's read after the label ("Messages 3").
5727
+ - `badgeLabel`: `string`. Screen-reader text for the badge, e.g. "3 unread messages". Replaces the badge text in the accessible name.
5728
+ - `badgeTone`: `Tone`. Badge color. By default `accent`, or the bar's colors swapped on the `solid` variant.
5729
+ - `children`: `ReactNode` (required). The label. Always the item's accessible name, even when hidden by `labels`.
5730
+
5731
+ ### Examples (Storybook stories)
5732
+
5733
+ - Playground
5734
+ - Effects: Every `effect`. Tap the items to play each one. `effect="none"` turns the effect off; the bubble still slides. With reduced motion, none play.
5735
+ - Placements: Bottom tab bar, top bar, and a side rail at either edge.
5736
+ - Labels: Labels on every item, only on the current one (it grows into a pill), or icons only.
5737
+ - Variants And Tones: Surface and solid bars in every active tone.
5738
+ - Sizes
5739
+ - Floating: A rounded island with space around it, as a bar and as a rail.
5740
+ - Active Icons: `activeIcon` swaps in a filled icon on the current item, an extra cue besides color.
5741
+ - Router Controlled: With a router: each item's `active` says which page is current, and the root holds no state.
5742
+ - Long Labels: Long labels shorten with an ellipsis instead of pushing other items out.
5743
+ - Right To Left: Right-to-left: items run from the right, and a start rail sits on the right.
5744
+ - Fixed: `position="fixed"` (the default in apps): the bar stays on the viewport's bottom edge, and `<html>` gets scroll padding and `--mobile-nav-offset` so focused content isn't hidden behind it.
5745
+
5675
5746
  ## Navbar
5676
5747
 
5677
5748
  import { Navbar } from "@vjdesigns/vjdesigns-ui";