AI
Language Switcher
A controlled locale picker dropdown in icon and pill variants; the host owns the locale change.
A locale picker dropdown. It is controlled — you supply the available locales, the currentLocale, and an onChange handler. The host owns the actual locale change (cookie, reload, or router push). It closes on outside click and comes in icon and pill variants.
Import
import { LanguageSwitcher } from "@yuhuanowo/yunui/ai";
Basic
Hold the current locale in state; in a real app onChange would set a cookie and refresh.
Basic
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| align | "left" | "right" | right | Dropdown alignment |
| className | string | — | Additional className |
| currentLocale* | string | — | Currently active locale value. |
| label | string | Language | Accessible label for the trigger. |
| locales* | LanguageOption[] | — | Available languages. The host app supplies these. |
| onChange* | (locale: string) => void | — | Called when the user picks a different locale. Host owns cookie/reload. |
| pending | boolean | false | Disables the control while a change is in flight. |
| variant | "icon" | "pill" | icon | Visual variant |