Default
No background: the globe, the current language and a caret.
Lets people read the site in the language they understand best. It sits at the right of the masthead pre-header and opens a short list of links to the same page in the other languages.
Updated
Language switcher
HTML
<nav class="nds-language-switcher nds-language-switcher--desktop" aria-label="Language"> <div class="nds-language-switcher__inner"> <button type="button" class="nds-language-switcher__trigger" id="language-switcher-trigger" aria-expanded="false" aria-controls="language-switcher-menu" aria-label="Language: English" > <span class="nds-language-switcher__icon" aria-hidden="true"> <svg class="nds-language-switcher__icon-svg" focusable="false"> <use href="#nds-icon-globe"> </use> </svg> </span> <span class="nds-language-switcher__current"> English </span> <span class="nds-language-switcher__caret" aria-hidden="true"> <svg class="nds-language-switcher__caret-svg" focusable="false"> <use href="#nds-icon-caret"> </use> </svg> </span> </button> <div class="nds-select__menu nds-language-switcher__menu" id="language-switcher-menu" hidden> <p class="nds-select__menu-header"> Select a language </p> <ul class="nds-select__menu-list" role="listbox" aria-label="Language"> <li class="nds-language-switcher__item"> <a class="nds-select__menu-option nds-select__menu-option--chosen" href="/en/" lang="en" hreflang="en" aria-current="true"> <span class="nds-select__menu-option-label"> English </span> <svg class="nds-select__menu-option-check" aria-hidden="true" focusable="false"> <use href="#nds-icon-check"> </use> </svg> </a> </li> <li class="nds-language-switcher__item"> <a class="nds-select__menu-option" href="/ha/" lang="ha" hreflang="ha"> <span class="nds-select__menu-option-label"> Hausa </span> </a> </li> <li class="nds-language-switcher__item"> <a class="nds-select__menu-option" href="/ig/" lang="ig" hreflang="ig"> <span class="nds-select__menu-option-label"> Igbo </span> </a> </li> <li class="nds-language-switcher__item"> <a class="nds-select__menu-option" href="/yo/" lang="yo" hreflang="yo"> <span class="nds-select__menu-option-label"> Yorùbá </span> </a> </li> </ul> </div> </div></nav> Block
<!-- wp:nds/language-switcher {} --><nav class="nds-language-switcher nds-language-switcher--desktop" aria-label="Language"> <div class="nds-language-switcher__inner"> <button type="button" class="nds-language-switcher__trigger" id="language-switcher-trigger" aria-expanded="false" aria-controls="language-switcher-menu" aria-label="Language: English" > <span class="nds-language-switcher__icon" aria-hidden="true"> <svg class="nds-language-switcher__icon-svg" focusable="false"> <use href="#nds-icon-globe"> </use> </svg> </span> <span class="nds-language-switcher__current"> English </span> <span class="nds-language-switcher__caret" aria-hidden="true"> <svg class="nds-language-switcher__caret-svg" focusable="false"> <use href="#nds-icon-caret"> </use> </svg> </span> </button> <div class="nds-select__menu nds-language-switcher__menu" id="language-switcher-menu" hidden> <p class="nds-select__menu-header"> Select a language </p> <ul class="nds-select__menu-list" role="listbox" aria-label="Language"> <li class="nds-language-switcher__item"> <a class="nds-select__menu-option nds-select__menu-option--chosen" href="/en/" lang="en" hreflang="en" aria-current="true"> <span class="nds-select__menu-option-label"> English </span> <svg class="nds-select__menu-option-check" aria-hidden="true" focusable="false"> <use href="#nds-icon-check"> </use> </svg> </a> </li> <li class="nds-language-switcher__item"> <a class="nds-select__menu-option" href="/ha/" lang="ha" hreflang="ha"> <span class="nds-select__menu-option-label"> Hausa </span> </a> </li> <li class="nds-language-switcher__item"> <a class="nds-select__menu-option" href="/ig/" lang="ig" hreflang="ig"> <span class="nds-select__menu-option-label"> Igbo </span> </a> </li> <li class="nds-language-switcher__item"> <a class="nds-select__menu-option" href="/yo/" lang="yo" hreflang="yo"> <span class="nds-select__menu-option-label"> Yorùbá </span> </a> </li> </ul> </div> </div></nav><!-- /wp:nds/language-switcher --> Usage
import { LanguageSwitcher } from "@nigerian-design-standards/react";<LanguageSwitcher current="en" languages={languages} /> Use it on any NDS site that is published in more than one language. It belongs on the right of the masthead pre-header, on every page, so people find it before they have to read anything else.
The trigger’s states. The menu uses the shared dropdown option states.
No background: the globe, the current language and a caret.
surface/container behind it, and the text underlined.
1px white gap and a border/focus ring. Never removed.
The background stays, the caret turns up and the menu opens below.
The properties of the language switcher. The same in HTML and React. In WordPress, the theme adds it.
| Property | Type | Possible values | Description |
|---|---|---|---|
| current | string |
| The page’s language. The trigger shows it in its own name. |
| languages | array |
| Only the languages the site has: English first, then the rest in alphabetical order of their own names. |
| label | string |
| The accessible name of the nav. Defaults to “Language”. |
In code: <nav aria-label="Language"> with a <button aria-expanded aria-controls> and a <ul> of links. Each
link has lang and hreflang; the current one has aria-current="true". The globe and caret are aria-hidden.
| Part | Token | Contrast on the page |
|---|---|---|
| Trigger text | Label/medium · text/primary | 17.6:1 |
| Globe and caret (16px) | icon/globe · icon/caret · size/icon/sm · text/primary | 17.6:1 |
| Hover and open | surface/container behind the trigger, plus an underline on hover | — |
| Focus ring | border/focus with a 1px surface/canvas gap | 4.5:1 |
| Trigger size · corners | 28px desktop, 44px mobile · spacing/050 to spacing/150 · radius/050 | — |
| Menu | Form/Dropdown menu: surface/canvas, 1px border/default, radius/100, 240px wide | Border is decorative |
| Options | Form/Dropdown option: Body/medium, 40px rows. Selected adds medium text and a check | 17.6:1 |
Write each language in its own name, with English first.
Don’t use codes like EN or HA, or flags. They mean nothing to many readers.
Where the switcher sits and how much room it takes.
How to name and order the languages.
English, Hausa, Igbo, Yorùbá: each in its own language and spelling.
A flag is a country, not a language. EN or HA mean nothing to many readers.
Then the others in alphabetical order of their own names.
The list comes from the translation plugin. A site with only English hides the switcher.
| Write | Don’t write | Why |
|---|---|---|
| Yorùbá | Yoruba | Its own name, with tone marks. |
| Hausa | HA | A code means nothing to many readers. |
| English | UK flag and English | Flags stand for countries, not languages. |
| Igbo | Igbo language | Just the name. |
| Language: English | Change language | The button’s accessible name says the current language. |
The switcher is a button that opens a list of links, one per language.
| Key | What it does |
|---|---|
| Tab | Reaches the trigger. When open, moves through the language links; tabbing past the last link closes the menu. |
| Esc | Closes the menu and returns focus to the trigger. |
| Enter or Space | Opens and closes the menu. On a link, Enter goes to that language. |
Copy the code for HTML, WordPress or React from the Code tab in Live example. The options are listed under Specifications.
Use Language switcher from 01 Library – Foundations. Pick the State and Size, and show only the languages the site has in the menu. Don’t detach it.
Is this page useful?