Skip to content
SENVENLI UI

Language switcher

Picks the interface language: each option named in the current language and sorted by that name, with an optional mark (a flag, a code chip) supplied by the app.
The product's languages
import { LanguageSwitcher, LanguageLabel } from "@senvenli/react/action";

Examples

With a mark

A renderMark function puts a code chip (or a flag) before each name.

Compact and collapsed

The small size for dense bars, and the mark alone for a collapsed rail.

Guidelines

When to use it

  • The header or sidebar of a product offered in several languages.

Use something else when

  • The language is one form field among others. Select
  • The language sits among other account actions. Menu

Accessibility

Keyboard

KeysWhat happens
Arrow up / downMoves between languages.
EnterChooses the focused language.

Built in

  • A listbox with the current language selected and checked.
  • Names never fall back to the host's language.
  • A mark is decorative; the name always tells options apart.

You provide

  • The product's locales, and names for languages Intl names wrongly (registerLanguageNames).

API reference

LanguageSwitcher

localesRequired
readonly Locale[]

Locales to offer, already narrowed to what this product enables.

valueRequired
Locale

The active UI locale.

onChangeRequired
(locale: Locale) => void

Called with the picked locale (routing, persistence).

label
string

The trigger's accessible name and tooltip; "Language" (the DS string) by default.

isLoading
booleanDefault false

Hold the disabled trigger while the product's locale list resolves.

variant
"button" | "sidebar"Default "button"

button (default): a trigger in a bar. sidebar: a full-width row whose list opens upward, for a panel sidebar.

isCollapsed
booleanDefault false

A collapsed rail: the mark alone (or the name, without one), kept for screen readers either way.

renderMark
(locale: Locale) => ReactNode

A mark before each language's name: a flag, an IsoChip, an icon. None by default: a language is not a country, and the name alone tells the options apart.

size
"small" | "medium"Default "medium"

Control height: medium (default) matches the DS controls, small is the compact step.

aria-describedby
string

Ids of elements that describe the trigger ("Changes the language of the whole panel"). It lands on the trigger button, the focusable control, also while it is disabled for isLoading; left out, nothing is added. While the trigger's tooltip is open it takes the place of the tooltip's id, which only repeats label.

LanguageLabel

localeRequired
string
uiLocaleRequired
string
hideName
booleanDefault false
mark
React.ReactNode