Skip to content

Locale Provider ​

Gives a locale to the Vase UI parts below it.

Anatomy ​

Import the component and wrap it around your app:

vue
<script setup lang="ts">
import { LocaleProvider } from '@vase-ui/vue/locale-provider';
</script>

<template>
  <LocaleProvider locale="de-DE">
    <!-- Your app or a group of components -->
  </LocaleProvider>
</template>

Which locale a part uses ​

A part with a locale prop formats its text, or compares the text of its items, in the first locale of this list:

  1. The locale prop of the part.
  2. The locale of the nearest LocaleProvider above the part.
  3. en-US.
vue
<script setup lang="ts">
import { LocaleProvider } from '@vase-ui/vue/locale-provider';
import { Meter } from '@vase-ui/vue/meter';
</script>

<template>
  <LocaleProvider locale="de-DE">
    <!-- 42 % -->
    <Meter.Root :value="42" aria-label="Storage">
      <Meter.Value />
    </Meter.Root>
    <!-- 42% -->
    <Meter.Root :value="42" locale="en-US" aria-label="Battery">
      <Meter.Value />
    </Meter.Root>
  </LocaleProvider>
</template>

These parts are the roots of Meter, Progress, Slider, Number Field, Date Field, Time Field, Time Clock, Calendar, Range Calendar, Date Picker, Date Range Picker, Time Picker, Combobox and Autocomplete, and Menu.FilterProvider. useFilter of Combobox and Autocomplete uses the same list for its locale option.

A part never uses the locale of the browser, because a server cannot know that locale. The server HTML and the page in the browser thus have the same text, and the text does not change after the hydration. Give the locale of the page to the provider, so that the text has the language of the page.

A change of the locale prop of the provider reaches each part below it.

API reference ​

LocaleProvider ​

Gives a locale to the Vase UI parts below it. A part that formats its text, or compares the text of its items, uses this locale when its locale prop has no value. Doesn't render its own HTML element.

Props

PropTypeDefaultDescription
localestringRequiredThe locale of each part below the provider whose locale prop has no value, such as de-DE.

Slots

SlotSlot propsDescription
defaultThe content of the part.

Differences from Base UI ​

Base UI has no Locale Provider. A developer gives the locale of the page one time, and each part below the provider uses that locale, on the server and in the browser.

The handbook gives the differences that all components share: Styling, Animation, Composition, Customization, Forms and TypeScript.