Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Layout & primitives

LocaleProvider

Free9.9 KB gzipped

Sets the language of every component inside: built-in labels and screen-reader text, date and number formats, plurals, and writing direction. Wraps its children in an element with lang and dir (display: contents, so layout is unaffected); overlays opened inside keep the language.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · No keyboard interaction of its own · Full report

Import

tsx
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";

Importing only LocaleProvider adds about 9.9 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

Wrap any part of your app in LocaleProvider with a locale and its messages. Every component inside uses that language for its built-in text, dates and numbers.

No hay resultados para «zapatillas»

Prueba con otra búsqueda o borra los filtros.

tsx
import {
  EmptyState,
  LocaleProvider,
  Pagination,
  Stack,
} from "@vjdesigns/vjdesigns-ui";
import es from "@vjdesigns/vjdesigns-ui/locales/es";

export function Basic() {
  return (
    <LocaleProvider locale="es" messages={es}>
      <Stack gap={4} align="center">
        <EmptyState kind="no-results" query="zapatillas" />
        <Pagination pageCount={8} defaultPage={3} />
      </Stack>
    </LocaleProvider>
  );
}

Override strings

Pass only the strings you want to change. Everything else falls back to the outer provider's language (English at the top), and per-component props such as clearLabel still win.

tsx
import { LocaleProvider, Pagination } from "@vjdesigns/vjdesigns-ui";

export function OverrideStrings() {
  return (
    <LocaleProvider locale="en-GB" messages={{ pagination: { next: "Onwards", previous: "Back" } }}>
      <Pagination pageCount={8} defaultPage={3} />
    </LocaleProvider>
  );
}

Nested

Providers nest: an inner provider switches the language for its part of the page, and sets lang there so screen readers switch pronunciation too.

Cette partie est en français :

tsx
import {
  LocaleProvider,
  SearchInput,
  Stack,
  Text,
} from "@vjdesigns/vjdesigns-ui";
import fr from "@vjdesigns/vjdesigns-ui/locales/fr";

export function Nested() {
  return (
    <Stack gap={4} style={{ width: "100%", maxWidth: "22rem" }}>
      <SearchInput aria-label="Search" placeholder="Search in English" clearable defaultValue="shoes" />
      <LocaleProvider locale="fr" messages={fr}>
        <Stack gap={2}>
          <Text size="sm" tone="muted">
            Cette partie est en français :
          </Text>
          <SearchInput aria-label="Rechercher" placeholder="Rechercher" clearable defaultValue="chaussures" />
        </Stack>
      </LocaleProvider>
    </Stack>
  );
}

Right to left

Arabic, Hebrew, Persian and Urdu set dir="rtl" automatically: layouts mirror, the calendar starts on the locale's first weekday, and arrow keys follow the reading direction. Pass dir to override it.

أكتوبر 2026

السبتالأحدالاثنينالثلاثاءالأربعاءالخميسالجمعة
tsx
import { Calendar, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

export function RightToLeft() {
  return (
    <LocaleProvider locale="ar" messages={ar}>
      <Calendar aria-label="اختر تاريخًا" defaultValue="2026-10-14" />
    </LocaleProvider>
  );
}

Usage notes

tsx
import es from "@vjdesigns/vjdesigns-ui/locales/es";

<LocaleProvider locale="es" messages={es}>
  <App />
</LocaleProvider>

Providers nest: an inner provider changes the locale for its subtree and merges its messages over the outer ones.

API reference

LocaleProvider

New in 1.3.0
LocaleProvider props
PropTypeDefault
localeRequired

BCP 47 language tag, e.g. "es", "pt-BR", "ar". Sets lang on the wrapper and the locale for dates, numbers, and plurals in every component.

string—
messages

Built-in strings for the language, e.g. import es from "@vjdesigns/vjdesigns-ui/locales/es". Partial messages are merged over the outer provider's (English at the top), so you can also override just a few strings. Leave unset to keep the outer messages.

PartialMessages—
dir

Writing direction. Defaults to the locale's: "rtl" for Arabic, Hebrew, Persian, Urdu, and other right-to-left languages.

"ltr""rtl"—
childrenReactNode—

See what changed in each version in the Changelog.

Accessibility report

LocaleProvider targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

37 passed · 0 failed · 28 not applicable · 10 to check by hand

Dark mode

Score 100

37 passed · 0 failed · 28 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Not focusable, so there's no keyboard interaction of its own.

Roles and states

Roles and states
ElementRoleStates and properties
Wrapper <div>none (generic)lang and dir for its subtree

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)