Skip to main content
Urbicon UI
source

LocaleSwitcher

Dropdown for switching the application's display language.

Playground

Variant
Size
<LocaleSwitcher
  size="sm"
  variant="outlined"
/>

01 Examples

LocaleSwitcher reads and sets the language through the app's i18n setup, so mount it under your <I18nProvider>. Pass locales to choose which languages it offers.

Restrict the languages

Only the languages you list appear, in that order.
<LocaleSwitcher showFlag locales={['en', 'de', 'fr']} />

In a settings panel

A language row inside a settings card.

Preferences

Language

Region

<div
  class="bg-surface-elevated border-border-subtle w-full overflow-hidden rounded-2xl border"
>
  <div class="border-border-subtle border-b px-5 py-3">
    <h3 class="text-text-primary text-sm font-semibold">Preferences</h3>
  </div>
  <div class="divide-border-subtle divide-y">
    <div class="flex items-center justify-between px-5 py-3">
      <p class="text-text-primary text-sm font-medium">Language</p>
      <LocaleSwitcher variant="outlined" size="sm" showFlag />
    </div>
    <div class="flex items-center justify-between px-5 py-3">
      <p class="text-text-primary text-sm font-medium">Region</p>
      <Select
        options={[
          { label: 'Europe', value: 'eu' },
          { label: 'North America', value: 'na' },
          { label: 'Asia', value: 'asia' }
        ]}
        value="eu"
        variant="outlined"
        size="sm"
      />
    </div>
  </div>
</div>

02 Customization

Primary-tinted trigger

The slotClasses prop restyles individual parts: the trigger, its chevron, the open list. Your classes are added to the built-in ones, so the default sizing and keyboard behaviour stay.
<LocaleSwitcher
  showFlag
  slotClasses={{
    trigger: 'bg-primary-subtle border-primary text-primary hover:border-primary',
    chevron: 'text-primary',
    listbox: 'border-primary'
  }}
/>

This is one of five ways to restyle a block. See Customization for class, slotClasses, unstyled, preset and provider-level overrides.

03 Accessibility

Built-in ARIA

Inherits the Select listbox semantics: role="listbox", aria-expanded and aria-selected, plus a trigger aria-label.

Keyboard

navigate, Enter selects, Esc closes.

Localized names

Each option's language name is shown in the current language.

04 API Reference

6 props
6 props
Prop
Type
Default
Description

05 Types

Local type definitions used by this component.

4 types
Name
Kind
Category
Used by
Description

06 Installation

Import

import { LocaleSwitcher } from '@urbicon-ui/blocks';