Skip to content
OAIT Design System

Design system / Components

Language switcher

The control that shows the page's language and changes it: a disclosure listing every language in its own script when a product has three, a direct link or button to the other language when it has two.

When to use

  • On every page of every product: first in the header's end cluster, in the app bar, at the end of the footer's legal bar, inside the phone menu sheet when the header collapses, on sign-in pages. Never only in the footer (canonical §10.28).
  • Three or more languages (Global ID and Tamakkan's app today; any product that adds French): the disclosure.
  • Two languages (oait.app, Global Jobs, Global Games today, Tamakkan's landing): the direct link or button.

When not to use

Need Use instead
Choosing the language of something else (an invitation, a document) A select or radios inside the form
A first-run language question inside a flow (Tamakkan's assessment) Choice cards may stay inside the flow; the header still carries the switcher (D-BCP-29)
Showing both sides of a bilingual object (the ID card's English and Arabic faces) A segmented button
Row actions, "More", an account menu An action menu

Anatomy

Three or more languages, div.oa-lang:

  1. Trigger (button.oa-lang__trigger) with aria-expanded, aria-controls, and aria-label="Language: English", holding, in this order:
    1. the translate icon: 20px beside the label, 24px when the trigger is icon-only;
    2. the current language in its own script (.oa-lang__current);
    3. the arrow_drop_down icon, 20px.
  2. List (ul.oa-lang__list.oa-menu, the menu container): hidden while closed; data-side="top" opens it upward. The list composes the menu's classes, so the two can never drift; .oa-lang__list only places it (canonical §10.20).
  3. Options (.oa-lang__option.oa-menu__item, the word in .oa-menu__label, the check in .oa-menu__check): <a href hreflang lang> in URL products, <button type="button" lang> in cookie products. Every option holds the check; it shows on the one with aria-current="true", after its word.

Two languages, a.oa-lang.oa-lang--two or button.oa-lang.oa-lang--two:

  1. The translate icon, 20px.
  2. The other language's endonym, tagged: <span lang="ar">العربية</span>.
  3. Context for screen readers in the page's language: <span class="oa-visually-hidden">Switch to Arabic</span>.

Variants

Variant Use for Element Key tokens
Disclosure with buttons Cookie products with three languages: Global ID and Tamakkan's app; Global Games, Security, Tasks, Events, and Tests when they add French a button and a list of buttons --color-on-surface, --color-surface-raised, --shadow-elevation-3, --color-primary-ink (the check)
Disclosure with links URL products with three languages (oait.app, Global Jobs, or Tamakkan's landing, if they add French) a button and a list of links with hreflang the same
Two languages, link URL products: oait.app, Global Jobs, Tamakkan's landing <a href hreflang> to the same page in the other language --color-on-surface
Two languages, button Cookie products with two languages: Global Games today <button type="button"> --color-on-surface

URL products keep the language in the path (/en/…, /ar/…); app-led products keep it in the account and the cookie, never in the URL (canonical §14.1, D-BCP-28).

Sizes

Part Height Padding and gaps Type style Icon
Trigger with its label, from 768px 48px, --size-touch-target (h-12) 12px inline (px-3), 6px between parts (gap-1.5) label-md 14/20 600 translate and arrow_drop_down 20px, --size-icon-md
Trigger, icon-only, below 768px 48 × 48px (size-12) none none translate 24px, --size-icon-lg
Two-language toggle 48px 12px inline, 8px gap (gap-2) label-md translate 20px
List (the menu container) content height 8px block (py-2); 200px wide at least (--size-menu-min, min-w-50), 320px at most (--container-menu, max-w-menu) none none
Option (a menu row) 48px at least, --size-menu-item (min-h-12) 16px inline (--space-row-inset, px-4), no block padding (the 48px minimum centers the word), 12px gap body-lg 16/24 check 20px

Tokens

Part Property Token (Tailwind)
Trigger, toggle height, minimum width --size-touch-target (h-12, min-w-12)
Trigger, toggle label and icons --color-on-surface (text-on-surface); --text-label-md with its companions (text-label-md)
Trigger, toggle corner, edge --radius-full (rounded-full); 1px transparent border
Trigger, toggle gaps --space-1-5 (trigger), --space-2 (toggle); padding --space-3
Icons size --size-icon-md beside a label, --size-icon-lg icon-only
List (.oa-menu) surface --color-surface-raised (bg-surface-raised), --shadow-elevation-3 (shadow-elevation-3), --radius-box (rounded-box), 1px transparent border
List (.oa-menu) width, layer --size-menu-min, --container-menu; --z-dropdown (z-40)
List (.oa-lang__list) offset from the trigger --space-1 (mt-1, or mb-1 above)
Option (.oa-menu__item) height, padding --size-menu-item; --space-row-inset inline, no block padding; --space-3 gap
Option (.oa-menu__item) text --color-on-surface, --text-body-lg (text-body-lg)
Check (.oa-menu__check) color, size --color-primary-ink (text-primary-ink), --size-icon-md
State layer opacity --opacity-state-hover (0.08), --opacity-state-pressed (0.12), fading over --duration-short-3 with --ease-standard; on the trigger and the toggle it covers the 1px border
Option ring offset --size-focus-inset (−4px)
List motion enter, exit opacity and a 4px rise over --duration-short-3 with --ease-emphasized; the exit fades over --duration-short-3 with --ease-emphasized-accelerate

States

State What changes
Enabled Label and icons in on-surface; no fill.
Hover Trigger, toggle, and options: the state layer of the label color at 8%, fading in over --duration-short-3 (pointer devices only). On the trigger and the toggle the layer covers the 1px border, so no lighter rim shows.
Focus-visible Trigger and toggle: the base ring around the pill. Options: the ring inset 4px inside the list's row (canonical §6.3).
Pressed The layer at 12%, shown at once.
Expanded aria-expanded="true"; the list shows. The trigger keeps its look and the arrow does not turn, as in Global ID today.
Current The option with aria-current="true" carries a 20px check in primary-ink at the inline end: the cue that is not color (canonical §10.0).
Saving (cookie products) While the choice saves, the trigger has aria-busy="true"; the save takes under a second, so no spinner shows (canonical §10.23). Options are disabled (on-surface at 38%) if the list is opened again meanwhile.
Error The snackbar "We couldn’t change the language. Try again."; the page stays in its language and focus stays on the trigger.
Disabled Never: the switcher is always available.

Behavior

Disclosure, the script contract. It is a disclosure, not an ARIA menu (canonical §10.20):

  1. Enter, Space, or a press on the trigger toggles hidden on the list and aria-expanded on the trigger.
  2. Tab and Shift+Tab move through the options in order. No arrow keys, no type-ahead.
  3. Escape closes the list and returns focus to the trigger; a press outside it, or focus leaving the switcher, closes it.
  4. Choosing a language closes the list. A cookie product returns focus to the trigger, saves the choice, and re-renders the page; a URL product follows the link.

Placement. The list opens under the trigger, aligned to its inline end, 4px apart. Near the bottom of the window and at the end of the footer's legal bar it opens upward: set data-side="top" on the list (canonical §10.16, §10.20).

Switching.

  • The switch keeps the page: the same path and query in the other language (/en/jobs → /ar/jobs), and form input where it can (D-BCP-29).
  • Every switcher writes the family cookie oait_locale=<en|ar|fr>; Domain=oait.app; Path=/; Max-Age=31536000; SameSite=Lax; Secure (Tamakkan, at tamakkan.oait.app, is covered by the same cookie, D-BCP-45). The server validates it against the product's languages; anything else falls back to English. A signed-in person's saved language wins over the cookie (canonical §14.1).
  • The page re-renders with the new lang and dir on <html>, from the server.
  • No automatic detection: Accept-Language is not read, so a first visit is in English and the switcher is always visible (D-BCP-28).
  • Global ID's gid_locale and Global Games' gg_locale are still read for 12 months, then retired.

Responsive.

  • The three-language trigger is icon-only below 768px: a 48 × 48 circle with a 24px translate, still named "Language: English" (canonical §10.28, C-7).
  • In a console's top app bar the switcher is an icon too (D-CSN-58): the same 48 × 48 form and the same names; the reference CSS does it inside .oa-app-shell--drawer. The member app's bar is unchanged.
  • In a site header the switcher is an icon at every width (D-CSN-57): 48 × 48 with a 24px translate, for both forms. The reference CSS does this inside .oa-site-header, so the markup does not change: the three-language trigger keeps its aria-label, and the two-language link keeps its endonym and "Switch to Arabic" for screen readers, hidden from sight. In a site header with a menu it still moves into the menu sheet below 640px, where it shows its words; a header with no menu keeps the icon in the bar (canonical §10.14).
  • In a footer and in the menu sheet the switcher keeps its words: the two-language toggle shows the other language's endonym, which is how a reader of that language finds it; the three-language trigger shows the current language from 768px (D-CSN-57).

Motion. The list moves as the menu does: it fades in and rises 4px over --duration-short-3 with --ease-emphasized, and fades out over --duration-short-3 with --ease-emphasized-accelerate when hidden is set (the menu's CSS does both). A React (Radix) product may close it at once. Nothing moves under reduced motion, and no script waits for a transition to end (D-SEM-16, canonical §7.3, §7.7).

Accessibility

  • Trigger. <button type="button"> with aria-expanded and aria-controls, named "Language: English", "اللغة: العربية", or "Langue : Français" in the page's language. The name contains the visible word, so speech input works (WCAG 2.5.3). Icon-only, it also shows the plain tooltip with the same words on pointer devices (Tooltip).
  • List. A plain list of links or buttons in the Tab order; never role="menu", which promises arrow keys (canonical §10.20).
  • Options. Each option carries its lang (and hreflang on links), so screen readers switch voice; the current one has aria-current="true" and the check.
  • Two languages. The name is the visible endonym followed by the hidden context: "العربية Switch to Arabic". The visible word comes first (label in name).
  • Targets. 48 × 48px triggers and toggles; 48px option rows.
  • Contrast. on-surface on every surface (13.2:1 or more in light, 9:1 or more in dark); the check in primary-ink, 4.5:1 or more on surface-raised.
  • Errors. The failure message comes through the page's status region, the snackbar host (role="status").
  • Forced colors. The list keeps its 1px edge; disabled options turn GrayText (the browser's own rule for disabled buttons); the ring stays an outline.
  • Reduced motion. The list appears and leaves at once.

RTL and languages

  • The trigger's parts follow the direction; neither translate nor arrow_drop_down mirrors (canonical §8.3).
  • On an Arabic page the list opens at the inline end, the left, and its options align to the right.
  • The options keep one order in every language: English, العربية, Français.
  • French puts a no-break space (U+00A0) before the colon: "Langue : Français" (canonical §3.7).
  • Arabic options sit in their own lang, so they take the Arabic line height (28px) inside an English list. The menu's rows have no block padding, so every row stays 48px and the list stays even.

Content

  • Name every language in its own language and script, the language a person switches to: "العربية", never "Arabic" or "Arabe"; "Français", never "French" (D-BCP-29).
  • The trigger's name is "Language: {endonym}" in the page's language. The two-language toggle's hidden words say what a press does, in the page's language.
English page Arabic page French page
Trigger name Language: English اللغة: العربية Langue : Français
Options English · العربية · Français English · العربية · Français English · العربية · Français
Two-language hidden text Switch to Arabic التبديل إلى الإنجليزية none (two-language products ship English and Arabic)
Failure We couldn’t change the language. Try again. تعذّر تغيير اللغة. حاول مرة أخرى. Impossible de changer la langue. Réessayez.

All of these ship today in Global ID or Global Jobs.

Do and don't

Do Don't
Show the endonym, "العربية". Write "Arabic", "AR", or a globe with no word (Global Games today).
Keep the visible word in the accessible name: "العربية Switch to Arabic". Name the link "Read this page in Arabic", which drops the visible word (oait.app today).
Use a disclosure: Tab through the options, Escape to close. Use role="menu", a <select>, or language cards in the header (Tamakkan today).
Put the switcher first in the header's end cluster and in the footer. Put it only in the footer.
Keep the reader on the same page in the other language. Send them to the home page.
Write oait_locale from every switcher. Keep a cookie per product, or read Accept-Language.

Code

HTML (reference CSS)

Three languages in a cookie product (Global ID), closed:

<div class="oa-lang">
  <button class="oa-lang__trigger" type="button" aria-label="Language: English" aria-expanded="false" aria-controls="bk-lang-1">
    <span class="oa-icon" aria-hidden="true" translate="no">translate</span>
    <span class="oa-lang__current">English</span>
    <span class="oa-icon" aria-hidden="true" translate="no">arrow_drop_down</span>
  </button>
  <ul class="oa-lang__list oa-menu" id="bk-lang-1" hidden>
    <li><button class="oa-lang__option oa-menu__item" type="button" lang="en" aria-current="true"><span class="oa-menu__label">English</span><span class="oa-icon oa-menu__check" aria-hidden="true" translate="no">check</span></button></li>
    <li><button class="oa-lang__option oa-menu__item" type="button" lang="ar"><span class="oa-menu__label">العربية</span><span class="oa-icon oa-menu__check" aria-hidden="true" translate="no">check</span></button></li>
    <li><button class="oa-lang__option oa-menu__item" type="button" lang="fr"><span class="oa-menu__label">Français</span><span class="oa-icon oa-menu__check" aria-hidden="true" translate="no">check</span></button></li>
  </ul>
</div>

Three languages with links (a URL product):

<div class="oa-lang">
  <button class="oa-lang__trigger" type="button" aria-label="Language: English" aria-expanded="false" aria-controls="bk-lang-3">
    <span class="oa-icon" aria-hidden="true" translate="no">translate</span>
    <span class="oa-lang__current">English</span>
    <span class="oa-icon" aria-hidden="true" translate="no">arrow_drop_down</span>
  </button>
  <ul class="oa-lang__list oa-menu" id="bk-lang-3" hidden>
    <li><a class="oa-lang__option oa-menu__item" href="#bk-oait-en" hreflang="en" lang="en" aria-current="true"><span class="oa-menu__label">English</span><span class="oa-icon oa-menu__check" aria-hidden="true" translate="no">check</span></a></li>
    <li><a class="oa-lang__option oa-menu__item" href="#bk-oait-ar" hreflang="ar" lang="ar"><span class="oa-menu__label">العربية</span><span class="oa-icon oa-menu__check" aria-hidden="true" translate="no">check</span></a></li>
    <li><a class="oa-lang__option oa-menu__item" href="#bk-oait-fr" hreflang="fr" lang="fr"><span class="oa-menu__label">Français</span><span class="oa-icon oa-menu__check" aria-hidden="true" translate="no">check</span></a></li>
  </ul>
</div>

In a footer, set data-side="top" on the list: <ul class="oa-lang__list oa-menu" id="…" data-side="top" hidden>. In the kitchen sink, oa-lang--demo shows an open list in the page flow; it is documentation only.

Two languages: Global Jobs' link, and the same toggle as a button in a cookie product:

<a class="oa-lang oa-lang--two" href="#bk-jobs-ar" hreflang="ar">
  <span class="oa-icon" aria-hidden="true" translate="no">translate</span>
  <span lang="ar">العربية</span><span class="oa-visually-hidden">Switch to Arabic</span>
</a>
<button class="oa-lang oa-lang--two" type="button">
  <span class="oa-icon" aria-hidden="true" translate="no">translate</span>
  <span lang="ar">العربية</span><span class="oa-visually-hidden">Switch to Arabic</span>
</button>

On an Arabic page (<html lang="ar" dir="rtl">):

<div class="oa-lang">
  <button class="oa-lang__trigger" type="button" aria-label="اللغة: العربية" aria-expanded="false" aria-controls="bk-lang-ar-closed">
    <span class="oa-icon" aria-hidden="true" translate="no">translate</span>
    <span class="oa-lang__current">العربية</span>
    <span class="oa-icon" aria-hidden="true" translate="no">arrow_drop_down</span>
  </button>
  <ul class="oa-lang__list oa-menu" id="bk-lang-ar-closed" hidden>
    <li><button class="oa-lang__option oa-menu__item" type="button" lang="en"><span class="oa-menu__label">English</span><span class="oa-icon oa-menu__check" aria-hidden="true" translate="no">check</span></button></li>
    <li><button class="oa-lang__option oa-menu__item" type="button" lang="ar" aria-current="true"><span class="oa-menu__label">العربية</span><span class="oa-icon oa-menu__check" aria-hidden="true" translate="no">check</span></button></li>
    <li><button class="oa-lang__option oa-menu__item" type="button" lang="fr"><span class="oa-menu__label">Français</span><span class="oa-icon oa-menu__check" aria-hidden="true" translate="no">check</span></button></li>
  </ul>
</div>
<a class="oa-lang oa-lang--two" href="#bk-jobs-en" hreflang="en">
  <span class="oa-icon" aria-hidden="true" translate="no">translate</span>
  <span lang="en">English</span><span class="oa-visually-hidden">التبديل إلى الإنجليزية</span>
</a>

On a French page:

<div class="oa-lang">
  <button class="oa-lang__trigger" type="button" aria-label="Langue&#160;: Français" aria-expanded="false" aria-controls="bk-lang-fr">
    <span class="oa-icon" aria-hidden="true" translate="no">translate</span>
    <span class="oa-lang__current">Français</span>
    <span class="oa-icon" aria-hidden="true" translate="no">arrow_drop_down</span>
  </button>
  <ul class="oa-lang__list oa-menu" id="bk-lang-fr" hidden>
    <li><button class="oa-lang__option oa-menu__item" type="button" lang="en"><span class="oa-menu__label">English</span><span class="oa-icon oa-menu__check" aria-hidden="true" translate="no">check</span></button></li>
    <li><button class="oa-lang__option oa-menu__item" type="button" lang="ar"><span class="oa-menu__label">العربية</span><span class="oa-icon oa-menu__check" aria-hidden="true" translate="no">check</span></button></li>
    <li><button class="oa-lang__option oa-menu__item" type="button" lang="fr" aria-current="true"><span class="oa-menu__label">Français</span><span class="oa-icon oa-menu__check" aria-hidden="true" translate="no">check</span></button></li>
  </ul>
</div>

Tailwind CSS v4

<!-- Three languages -->
<div class="relative inline-flex">
  <button type="button" aria-label="Language: English" aria-expanded="false" aria-controls="lang-list" class="relative isolate inline-flex h-12 w-12 min-w-12 items-center justify-center gap-1.5 rounded-full border border-transparent px-0 text-label-md text-on-surface whitespace-nowrap cursor-pointer select-none md:w-auto md:px-3 before:pointer-events-none before:absolute before:-inset-px before:-z-1 before:rounded-[inherit] before:bg-current before:opacity-0 before:transition-opacity before:duration-short-3 before:ease-standard before:content-[''] hover:before:opacity-(--opacity-state-hover) active:before:opacity-(--opacity-state-pressed) active:before:duration-0">
    <Icon name="translate" class="text-(length:--size-icon-lg) md:text-(length:--size-icon-md)" />
    <span class="hidden md:inline">English</span>
    <Icon name="arrow_drop_down" class="hidden text-(length:--size-icon-md) md:inline-block" />
  </button>
  <ul id="lang-list" hidden class="absolute end-0 top-full z-40 mt-1 w-max min-w-50 max-w-menu list-none rounded-box border border-transparent bg-surface-raised px-0 py-2 text-on-surface shadow-elevation-3 transition-[opacity,translate] duration-short-3 ease-emphasized starting:opacity-0 starting:translate-y-1">
    <li><button type="button" lang="en" aria-current="true" class="relative isolate flex min-h-12 w-full items-center justify-between gap-3 px-4 text-start text-body-lg text-on-surface cursor-pointer focus-visible:-outline-offset-4 disabled:text-on-surface/38 before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:bg-current before:opacity-0 before:transition-opacity before:duration-short-3 before:ease-standard before:content-[''] hover:before:opacity-(--opacity-state-hover) active:before:opacity-(--opacity-state-pressed) active:before:duration-0">English<Icon name="check" class="text-(length:--size-icon-md) text-primary-ink" /></button></li>
    <!-- العربية (lang="ar"), Français (lang="fr") -->
  </ul>
</div>

<!-- Two languages -->
<a href="/ar/jobs" hreflang="ar" class="relative isolate inline-flex h-12 min-w-12 items-center justify-center gap-2 rounded-full border border-transparent px-3 text-label-md text-on-surface no-underline whitespace-nowrap before:pointer-events-none before:absolute before:-inset-px before:-z-1 before:rounded-[inherit] before:bg-current before:opacity-0 before:transition-opacity before:duration-short-3 before:ease-standard before:content-[''] hover:before:opacity-(--opacity-state-hover) active:before:opacity-(--opacity-state-pressed) active:before:duration-0">
  <Icon name="translate" class="text-(length:--size-icon-md)" />
  <span lang="ar">العربية</span><span class="sr-only">Switch to Arabic</span>
</a>

Opening upward: bottom-full mb-1 in place of top-full mt-1. Icon is the family icon component (canonical §8.1). shadcn/ui: build it from Popover, not DropdownMenu, which is an ARIA menu.

React

The family LanguageSwitcher (Global ID's LanguageMenu, extended for links and the two-language toggle):

Prop Type Default Description
languages { code: 'en' | 'ar' | 'fr'; name: string; href?: string }[] required Every language the product ships, named in its own script, in the order English, العربية, Français. href (with hreflang) in URL products. Two entries render the direct toggle.
current 'en' | 'ar' | 'fr' required The page's language.
label string required "Language: {name}" in the page's language.
switchLabel string none Two languages only: the hidden words, "Switch to Arabic".
opens 'down' | 'up' 'down' 'up' at the end of a footer.
onChange (code) => Promise<void> none Cookie products: saves the account preference and oait_locale, then re-renders.
failedMessage string required with onChange The snackbar when onChange fails: "We couldn’t change the language. Try again."
<LanguageSwitcher
  languages={[{ code: 'en', name: 'English' }, { code: 'ar', name: 'العربية' }, { code: 'fr', name: 'Français' }]}
  current={locale}
  label={t('language.current', { name: currentName })}
  onChange={setLocale}
  failedMessage={t('language.failed')}
/>