Skip to content

LanguageSwitch

The language of the interface. Each option is written in its own language, so anyone finds theirs.

import { LanguageSwitch } from '@sypnia/ui/react'

On this page
  1. English and Spanish
  2. When to use it
  3. For everyone
  4. Props

English and Spanish

Code
import { useState } from 'react';
import { LanguageSwitch } from '@sypnia/ui/react';

// Each language written in itself, so anyone finds theirs.
export default function Lang() {
  const [lang, setLang] = useState('en');
  return <LanguageSwitch value={lang} onChange={setLang} />;
}

When to use it

Use it when

  • In the top bar or the footer of sites and apps in more than one language.

Do not use it when

  • Flags: they stand for countries, not languages.

For everyone

  • Each option has its lang, so screen readers pronounce it right.

Props

LanguageSwitchTypeDefault
onChangerequired (id: string) => void
valuerequired string
options { id: string; label: string; }[] [{ id: 'en', label: 'English' }, { id: 'es', label: 'Español' }]
  1. English and Spanish
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms