Skip to main content
161

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Web docs
Actions

LanguageToggle

Coordinates controlled or persistent locale selection and document language as a compact accessible control.

FrameworksAstro · React · Elements

Registry commandlumen add LanguageToggle

InteractionNative markup

01

See it and copy it

Framework example

Choose Astro, React, or Elements to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.

AstroSame visual contract, native framework API

Framework usage

Switch targets to compare the adapter code. The preview stays visually stable because all three packages share the same tokens and ui-* class contract.
astro
---
import { LanguageToggle } from '@santi020k/lumen-astro'
---

<LanguageToggle
  defaultValue="en"
  storageKey="site-language"
  locales={[
    { label: 'English', value: 'en' },
    { label: 'Español', value: 'es' }
  ]}
/>
Edit LanguageToggle in browser
02

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add LanguageToggle
lumen add LanguageToggle

API reference

Lumen-specific props and runtime attributes for the Astro primitive. React props follow the same names; Elements use equivalent kebab-case attributes where custom elements expose them.

AttributeValuesDefaultDescription
localesLumenLocaleOption[]English and SpanishDefines the ordered locale values and human-readable labels to cycle through.
defaultValuestringfirst localeSets the initial locale for uncontrolled usage.
valuestring-Enables controlled usage; ui:language-change requests the next locale without mutating document language.
storageKeystring-Persists uncontrolled locale selection when browser storage is available.
labelTemplatestringChange language from {current} to {next}Localizes the accessible label while retaining current and next locale names.
childrenlocale label or custom contentnext locale labelOverrides the generated visible next-locale label.
type"button" | "submit" | "reset""button"Sets the native button type.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

Web docsFull catalog