<kern-language-select>
Language switcher: a dropdown with the language names («Deutsch», «English») or short codes («DE», «EN»), optionally with flags, or the languages side by side as links or buttons (variant="inline", good for two or three). Names are shown in their own language and marked with lang; codes are announced with the full name.
Languages come from languages (de,en,fr) or from child <option> elements, which may set their own name and flag: <option value="de-CH" data-flag="ch">Schweizerdeutsch</option>. With href (/{locale}/) every language is a real link. kernChange reports the choice; preventDefault() on it stops the navigation, so an app router can take over.
Examples
Dropdown
languages lists the codes; each language is shown by its own name («Deutsch», «Français»), marked with lang, so screen readers pronounce it correctly. kernChange reports { value }.
Choose a language.
Codes and flags
display="code" shows «DE», «EN»; screen readers still hear the full name. flags puts a flag in front: from the region of the code (de-CH → Switzerland), else the usual country of the language (en → United Kingdom). A flag names a country, not a language, so the name or code always stays next to it. When two entries share a language, the code includes the region.
Own names and flags
Child <option> elements replace languages and may set their own name (the text) or flag (data-flag), e.g. for a dialect Intl does not name well.
Side by side
variant="inline" lists the languages next to each other, the current one bold and not clickable. Good for two or three languages, e.g. in a footer or the topbar. With href every language is a real link ({locale} is replaced), with hreflang; without it they are buttons.
Switching the language
The switcher only reports the choice; the app changes its language and Kern's with setKernLocale() (or by setting <html lang>, which Kern follows). With href, preventDefault() on kernChange keeps the page so an app router can navigate instead; Ctrl/Cmd click on a link still opens a new tab.
Properties
disabledboolean
display"code" | "name"
name shows «Deutsch», code shows «DE».
flagsboolean
A flag before each language. A flag names a country, not a language: keep the name or code next to it.
hrefstring | undefined
Link per language; {locale} is replaced by the code, e.g. /{locale}/.
labelstring | undefined
Accessible name of the switcher.
languagesstring | string[]
Available languages, e.g. de,en,fr; child <option> elements win.
size"md" | "sm"
valuestring
Current language (BCP 47), e.g. de or de-CH.
variant"dropdown" | "inline"
dropdown, or inline for the languages side by side.
Events
kernChangeCustomEvent<{ value: string; href?: string | undefined; }>
A language was chosen. With href, preventDefault() keeps the page (e.g. to route in the app).
Slots
(default)<option> elements (read, not shown)
CSS parts
activeThe current language in the inline variant
itemEach language in the inline variant