LanguageSwitch
The language of the interface. Each option is written in its own language, so anyone finds theirs.
import { LanguageSwitch } from '@sypnia/ui/react'
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
| LanguageSwitch | Type | Default |
|---|---|---|
onChangerequired | (id: string) => void | |
valuerequired | string | |
options | { id: string; label: string; }[] | [{ id: 'en', label: 'English' }, { id: 'es', label: 'Español' }] |