Unlock faster development with Fidely UI Pro components Coming soon

Locale Provider

Use to set and access the active locale for your application

Usage

LocaleProvider defines the active locale for your application. It enables locale-aware behavior such as formatting and text direction across Fidely UI components.

import { LocaleProvider, useLocaleContext } from '@fidely-ui/react/locale'
<LocaleProvider locale=".....">Your App</LocaleProvider>

Most Fidely UI components automatically read the locale provided by LocaleProvider.


Examples

Setting Locale

Provide the locale prop with the locale you want to use.

<LocaleProvider locale="fr-FR">
  <YourComponent />
</LocaleProvider>

Reading the Locale

Access the current locale and text direction using useLocaleContext.

const App = () => {
  const { locale, dir } = useLocaleContext()

  return <pre>{JSON.stringify({ locale, dir }, null, 2)}</pre>
}

Props

PropDefaultTypeDescription
locale'en-US'stringThe locale to be use for the application.

On this page