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.
<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.
- groupPill-shaped group with a hairline.
- 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.
| Name | Type | Default | Description |
|---|---|---|---|
| options (required) | LanguageOption[] | – | value (language code), label (DE) and name (Deutsch). |
| value | string | – | Controlled language. |
| defaultValue | string | – | Initial language when uncontrolled. |
| onChange | (value: string) => void | – | Called with the chosen language. |
| label | string | "Language" | Names the group. |
Tokens used
Derived from the utility classes in the component's source. Copy a class with one click.
| Token | Tier | Value | Utility |
|---|---|---|---|
| pill.radius | component | 9999px | |
| border.hairline | semantic | rgba(10,10,11,0.08) | |
| focus | semantic | #C6492E | |
| motion.duration.fast | semantic | 150ms | |
| motion.ease.out | semantic | cubic-bezier(0.16, 1, 0.3, 1) | |
| spacing.1 | semantic | 4px | |
| spacing.3 | semantic | 12px | |
| spacing.6 | semantic | 24px | |
| surface.inverse | semantic | #0A0A0B | |
| surface.page | semantic | #FAFAF7 | |
| text.onInverse | semantic | #FAFAF7 | |
| text.primary | semantic | #0A0A0B | |
| text.secondary | semantic | #555555 | |
| type.meta.size | semantic | 13px | |
| weight.semibold | semantic | 600 |
Accessibility
What is checked automatically on every build, and what a person has tested. Nothing is marked as tested unless it was.
| Check | How | Status |
|---|---|---|
| axe-core rules | Automated on every npm run check, at desktop and mobile width | Runs on every build |
| Keyboard | Automated Playwright test (scripts/keyboard.mjs) | Tested |
| Screen reader | Manual | Not tested yet |
Keyboard
| Key | Action |
|---|---|
| Tab | Moves between the options. |
| Enter / Space | Switches 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
| Pairing | Ratio (x:1) | Minimum | Status |
|---|---|---|---|
| text.primary on surface.page | 18.92 | 4.5 | Pass |
| text.secondary on surface.page | 7.13 | 4.5 | Pass |
| text.onInverse on surface.inverse | 18.92 | 4.5 | Pass |
| focus on surface.page | 4.57 | 3.0 | Pass |
| surface.inverse on text.onInverse | 18.92 | 4.5 | Pass |