Molecule · stable · v1.0.0 · owner: Site system lead · contract 19 of 20 points (open: figma)
Do and don't
Do: Both languages
Rendered by language-switch.tsOpen example: Language switch · Do: Both languages Use the full-page example to follow page links.
Do: English-only page
Rendered by language-switch.tsOpen example: Language switch · Do: English-only page Use the full-page example to follow page links.
Don't: Hidden on English-only pages
Rendered by language-switch.tsOpen example: Language switch · Don't: Hidden on English-only pages Use the full-page example to follow page links.
Don't: A flag
Rendered by language-switch.tsOpen example: Language switch · Don't: A flag Use the full-page example to follow page links.
Rules
| Rule | Why | Check |
|---|---|---|
| The switch is on every page. | A header that shifts between pages looks broken, and readers must always find their language. | Automated: tests/site/pages.spec.ts (navigation test) |
API
| Prop | Type | Required | Default | What it does |
|---|---|---|---|---|
lang | en | ja | Yes | The page's language (marked current). | |
en | string | Yes | The English page. | |
ja | string | Yes | The Japanese page, or /ja/ when there is none. | |
jaMissing | boolean | No | false | The page has no Japanese version; the link says so. |
Contract details
The full contract: identity, anatomy, variants, states, tokens, layout, motion, accessibility, content, tests
Identity
| Aspect | Value |
|---|---|
| Id | language-switch |
| Layer | Molecules |
| Category | navigation |
| Owner | Site system lead |
| Status | stable |
| Version | 1.0.0 |
| Source | apps/showcase/site/system/molecules/language-switch.ts (private repository; the contract and the render function are this one module) |
| Version | Date | Change |
|---|---|---|
| 1.0.0 | 2026-10-26 | EN and 日本語 on every page; a page with no Japanese version links to the Japanese home and says so. |
Use when
- In every header. Why: Japanese prospects must always find their language in the same place.
Do not use when
- Inside content. Why: Language is a site setting, not a content link.
Anatomy
| Part | What it is |
|---|---|
| root | div.lang-switch, role=group, labelled Language |
| en | a, lang=en |
| ja | a, lang=ja; titled when the page has no Japanese version |
Made of: tokens:type, tokens:colour.
Used in: header.
Variants
| Variant | When | Why |
|---|---|---|
| pair | The page exists in both languages. | Each link goes to the same page in the other language. |
| english only | No Japanese version yet. | The link goes to the Japanese home and its title says why, so nobody lands on a missing page. |
States
| State | Rendered or not applicable |
|---|---|
| default | Two outlined links |
| hover | Background --surface-2. |
| focus-visible | The --focus ring. |
| active | Not applicable: Navigation is instant. |
| disabled | Not applicable: The Japanese link always goes somewhere (the Japanese home when the page has no version). |
| loading | Not applicable: Static. |
| empty | Not applicable: Always two languages. |
| error | Not applicable: Links are checked at build. |
| current | The page's language: ink background, aria-current=true. |
| visited | Not applicable: Same colours. |
| expanded | Not applicable: Not a menu. |
Tokens
| Part | Token |
|---|---|
| root.border | --rule-hair --ink |
| current.background | --ink |
| current.color | --cotton |
| link.font | --type-label |
| link.min-height | 36 px |
| --language-switch-border-rule-hair | var(--rule-hair) |
| --language-switch-border-ink | var(--ink) |
| --language-switch-border-radius-radius | var(--radius) |
| --language-switch-padding-space-4 | var(--space-4) |
| --language-switch-color-ink | var(--ink) |
| --language-switch-font-type-label | var(--type-label) |
| --language-switch-background-ink | var(--ink) |
| --language-switch-color-cotton | var(--cotton) |
| --language-switch-padding-space-3 | var(--space-3) |
Layout
| Aspect | Value |
|---|---|
| breakpoints | Required review at 390, 768, 1024 and 1440 px; execution is not implied by this declaration; always visible, also on phones. |
| wrapping | Never. |
| textExpansion | Fixed labels EN and 日本語. |
Spacing and rhythm
| Aspect | Value |
|---|---|
| internal | 0 --space-4 per link. |
| external | In the header actions, gap --space-4. |
| rhythm | Header only. |
Motion
| Aspect | Value |
|---|---|
| None | A language switch is a link. |
Runtime and reuse
Render-only element; mount any registered child enhancements separately. Preserve required Site CSS, fonts, responsive and locale rules from nativeElement.
Accessibility passport
| Aspect | Value |
|---|---|
| role | group of links, labelled Language (言語) |
| name | EN / 日本語 with lang attributes |
| keyboard | Tab to each link. |
| focus | Before the header CTA. |
| screenReader | Reads each language in its own voice (lang attributes); the current one is marked. |
| contrast | Ink on cotton 15.9:1, cotton on ink 15.9:1. |
| target | 44 by 36 px. |
Content
| Slot | Length | Voice |
|---|---|---|
| language names (fixed renderer text, not editable props) | EN and 日本語 exactly | Name languages in their own scripts. Do not substitute national flags or invent another language option. |
| missing Japanese destination explanation (fixed title) | The complete existing title: このページは英語のみです。日本語のトップページへ移動します。 | When jaMissing is true, explain that the link opens the Japanese home rather than a translation of the current page. |
Good: “EN · 日本語” · “このページは英語のみです。日本語のトップページへ移動します。”
Bad: “Language ▾” · “Country flags used as language names”
Japanese: 日本語 is a fixed language label; the group name is 言語 on Japanese pages. The supplied en/ja URLs and jaMissing determine the destination and title, not translated content props. Fixed Japanese strings remain subject to the existing native-review boundary.
Icons and illustrations
None: this element uses no icon or illustration of its own.
Decisions and exceptions
Usage
75 uses across the built pages (measured by npm run site:system).
Tests
| Aspect | Value |
|---|---|
| unit | tests/unit/site-system.test.ts: renders every do and don't example through the registry and checks the classes it owns |
| visual | Not yet: there are no screenshot baselines; the Library page is checked for sideways scroll at 1440 px by tests/site/system.spec.ts |
| a11y | tests/site/system.spec.ts: axe (0 serious or critical) on the element's Library page in light and dark |
| parity | scripts/site/system/check.ts: Library examples are rendered by the same render function the site imports |
Figma
not-yet: The Loom Site Figma library is the last stage of the plan; this element is not mapped yet.