YuhuanStudioYunUIDocs
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

PropTypeDefaultDescription
align"left" | "right"rightDropdown alignment
classNamestringAdditional className
currentLocale*stringCurrently active locale value.
labelstringLanguageAccessible label for the trigger.
locales*LanguageOption[]Available languages. The host app supplies these.
onChange*(locale: string) => voidCalled when the user picks a different locale. Host owns cookie/reload.
pendingbooleanfalseDisables the control while a change is in flight.
variant"icon" | "pill"iconVisual variant

On this page