Skip to content

Navigation

LanguageSwitch

Compact switch between page languages for the header; each option names its language in that language.

  • Experimental
  • Keyboard tested
  • Screen reader not tested yet

Playground

Change the props. The controls come from the documented props.
tsx
<LanguageSwitch
  defaultValue="en"
  options={[
    { value: "de", label: "DE", name: "Deutsch" },
    { value: "en", label: "EN", name: "English" },
  ]}
/>

Usage

When to use

Use the language switch in the header of pages that exist in more than one language.

When not to use

  • For choosing a language in a form: use RadioGroup or Select.

How it works

A small pill-shaped group of buttons; the selected language sits on ink and reports itself as pressed. Each option carries its lang attribute and its full name as accessible name.

Content guidelines

Short codes as labels (DE, EN), full names in their own language as accessible names (Deutsch, English). No flags.

Do and don’t

Do
  • Name each language in itself: Deutsch, English, Français.
Don’t
  • Don't use flags; flags are countries, not languages.

Anatomy

The parts of the component and what each one does, as in the playground above.
  1. groupPill-shaped group with a hairline.
  2. optionShort code; the selected one on ink.

Examples

Type-checked, and the same code goes into the AI manifest. Import: import { LanguageSwitch } from "@/ds";

German and English

Props

Checked against the component's TypeScript type on every build.
LanguageSwitch props
NameTypeDefaultDescription
options (required)LanguageOption[]–value (language code), label (DE) and name (Deutsch).
valuestring–Controlled language.
defaultValuestring–Initial language when uncontrolled.
onChange(value: string) => void–Called with the chosen language.
labelstring"Language"Names the group.

Tokens used

Derived from the utility classes in the component's source. Copy a class with one click.
Tokens used by LanguageSwitch
TokenTierValueUtility
pill.radiuscomponent9999px
border.hairlinesemanticrgba(10,10,11,0.08)
focussemantic#C6492E
motion.duration.fastsemantic150ms
motion.ease.outsemanticcubic-bezier(0.16, 1, 0.3, 1)
spacing.1semantic4px
spacing.3semantic12px
spacing.6semantic24px
surface.inversesemantic#0A0A0B
surface.pagesemantic#FAFAF7
text.onInversesemantic#FAFAF7
text.primarysemantic#0A0A0B
text.secondarysemantic#555555
type.meta.sizesemantic13px
weight.semiboldsemantic600

Accessibility

What is checked automatically on every build, and what a person has tested. Nothing is marked as tested unless it was.
Testing status by check
CheckHowStatus
axe-core rulesAutomated on every npm run check, at desktop and mobile widthRuns on every build
KeyboardAutomated Playwright test (scripts/keyboard.mjs)Tested
Screen readerManualNot tested yet

Keyboard

LanguageSwitch keyboard interactions
KeyAction
TabMoves between the options.
Enter / SpaceSwitches to the focused language.

Semantics and focus

  • Buttons with aria-pressed in a labelled group; the accessible name is the visible code plus the full language name.
  • Each option has its lang attribute, so screen readers pronounce the name correctly.

Contrast

LanguageSwitch contrast pairings
PairingRatio (x:1)MinimumStatus
text.primary on surface.page18.924.5Pass
text.secondary on surface.page7.134.5Pass
text.onInverse on surface.inverse18.924.5Pass
focus on surface.page4.573.0Pass
surface.inverse on text.onInverse18.924.5Pass