UI provider
In code: UIProvider
The language of the kit's own words and of its dates and numbers, set once for the whole app, around its content in the root layout. Words left out stay English. Without locale, dates follow the page's <html lang>.
Preview
Drop a file here, or paste it
Use
The code of the preview above
import { useState } from 'react';
import { DatePicker, FileDrop, Segmented, Stack, UIProvider, messages } from '@/components/ui';
function UIProviderDemo() {
const [lang, setLang] = useState('en');
return (
<Stack gap={4}>
<Segmented
aria-label="Language"
value={lang}
onValueChange={setLang}
items={[
{ value: 'en', label: 'English' },
{ value: 'de', label: 'Deutsch' },
]}
/>
<UIProvider
locale={lang === 'de' ? 'de' : 'en-GB'}
messages={lang === 'de' ? { dropFile: 'Datei hierher ziehen oder einfügen', chooseFile: 'Datei wählen', openCalendar: 'Kalender öffnen' } : undefined}
>
<Stack gap={4} key={lang} className="ui-appear">
<DatePicker aria-label="Arrival" defaultValue="2026-11-27" />
<FileDrop />
</Stack>
</UIProvider>
</Stack>
);
}Options
| Option | Type | What it does |
|---|---|---|
children Needed | ReactNode | What goes inside. |
locale | string | The language for dates and numbers, as a BCP 47 tag: "de", "en-GB". Left out, the page's <html lang> is used. |
messages | Partial<{ breadcrumb: string; pages: string; previousPage: string; nextPage: string; page: (n: number) => string; toolbar: string; previousMonth: string; nextMonth: string; month: string; year: string; endDate: string; clearDate: string; openCalendar: string; gallery: string; choosePage: string; previous: string; next: string; loading: string; search: string; searchPlaceholder: string; nothingFound: string; clear: string; showOptions: string; remove: (what: string) => string; less: string; more: string; capsLock: string; dropFile: string; chooseFile: string; files: string; code: string; copy: string; copied: string; colour: string; colourValue: (label: string) => string; pickFromScreen: string; readyColours: string; cropPicture: string; zoom: string; turnQuarter: string; mirror: string; resizePanel: string; mainMenu: string; openMenu: string; closeMenu: string; appearance: string; timeline: string; name: string; themeStyle: string; brandColour: string; greys: string; pageColour: string; pageWidth: string; fonts: string; lightOrDark: string; themeCode: string; done: string; notYet: string; unread: string; fileType: string; fileTooLarge: string; fileTooSmall: string; tooManyFiles: string; fileNotAdded: (name: string, reasons: string) => string; assistantAsk: string; allow: string; notNow: string; nothingChanged: string; undoAssistant: string; byAssistant: string; byTool: string; byYou: string; aControl: string; hidden: string; on: string; off: string; nothing: string; }> | The kit's own words in that language, by key; the ones left out stay English. |
Helpers: states, do and don’t
The language of the kit's own words, and of its dates and numbers, set once in the root layout (see Every language, every direction, every eye).
Hooks and functions the components are made of, passed on so a project uses the same ones: keyboard shortcuts, options loaded while typing, search matching, saved preferences, screen-reader announcements, smooth sizes, the theme.
Do
- Use
useShortcutfor app-wide keys, and show the key withformatShortcutso it reads right on each computer. - Use
announce()to tell a screen reader what changed when nothing visible takes focus ("3 results").
Don't
- Don't turn off the smooth sizes
Toasterstarts; boxes would jump when their content changes.