navigationhwcz-lsh

Theme Toggle

Button that applies a theme/group value as a class on the document root, persisted in localStorage and synced across instances.

Attributes

AttributeTypeDefaultDescription
valuestring''Value applied to the group when clicked (e.g. dark, light, or a theme class like theme-ocean).
groupstring''Configuration group the value belongs to; mode is special-cased to toggle the dark class on <html>.
prevent-autoupdatebooleanfalseOpts out of listening to other instances' z-lsh:change events.
togglebooleanfalseIn the mode group, flips between dark and light instead of applying a fixed value.
Inherited from Hwc
AttributeTypeDefaultDescription
i18nstring''Per-instance text overrides as key: text pairs, merged over the global z-i18n script and the built-in defaults.
floatingstring''Floating UI placement options (for example offset and shiftPadding) parsed as key: value pairs.
force-prevent-rerenderbooleanfalseSkips re-rendering after the first render; an existing data-host-inner child is adopted as the rendered DOM.
templatestring''Selector or id of an external element or <template> whose inner content is cloned in place of an inline template[data-fn="template"] child.
Inherited from Base
AttributeTypeDefaultDescription
clsstring''Adds classes to named parts as key: classes pairs; a plain string targets the default part.
stlstring''Adds inline styles to named parts as key: styles pairs; a plain string targets the default part.

Custom Styling (cls / stl)

Default cls target:button · defaultstl target:button

KeyDefault classclsstlDescription
buttonz-lshyesyesThe toggle button (default z-lsh); the default cls/stl target. Receives z-active while its value is active.

i18n Keys

KeyDefaultPlaceholdersDescription
active-labelActive—Suffix appended when the value is active.
aria-labelToggle theme—Base accessible label of the button.
switch-to-darkSwitch to dark mode—Toggle-mode label suffix when currently light.
switch-to-lightSwitch to light mode—Toggle-mode label suffix when currently dark.

Events

EventDetailFlagsDescription
z-lsh:before-change{ group: string; value: string; previousValue: string; config: { [group: string]: string; } }cancelable, bubblesCancelable; fires before applying a value. Detail: group, value, previousValue, config.
z-lsh:change{ group: string; value: string; previousValue: string; config: { [group: string]: string; } }bubblesFires after a value is applied and persisted, with the same detail; other instances sync from it.

Data Hooks

AttributeValuesApplies toRoleDescription
data-host-inner · from Hwc—descendantconfigMarks the rendered inner wrapper so force-prevent-rerender can adopt server-rendered DOM without re-rendering.
data-reactive · from Hwc—descendantconfigOpts the marked child (config script, data source, icons, or template) into live re-parsing when its DOM mutates.

Child Content

script[data-fn="config"][type="application/json"]

JSON configuration script parsed by the base class (i18n, cls, stl, floating).

AttributeRequiredTypeDescription
data-fnyesconfigMarks the script as configuration (value: config).
data-reactivenobooleanRe-parses the configuration when the script mutates.

select[data-fn="data-source"]

Hidden select parsed into grouped option data by the base class.

AttributeRequiredTypeDescription
data-fnyesdata-sourceMarks the select as the data source (value: data-source).
data-reactivenobooleanRe-parses the options when the select mutates.

optgroup · repeatable

Groups options under a label.

AttributeRequiredTypeDescription
labelyesstringGroup header text; also the default group key.
disablednobooleanDisables every option in the group.
data-keynostringOverrides the group key used in the parsed data.
data-keywordsnocomma-separated stringComma-separated keywords stored with the group's data.

option · repeatable

One option entry within the group.

AttributeRequiredTypeDescription
valuenostringValue carried by this option in the parsed data.
disablednobooleanMakes the option non-selectable.
selectednobooleanMarks the option as initially selected.
data-keywordsnocomma-separated stringExtra search terms, comma-separated; searched alongside the label and value.

option · repeatable

One ungrouped option entry.

AttributeRequiredTypeDescription
valuenostringValue carried by this option in the parsed data.
disablednobooleanMakes the option non-selectable.
selectednobooleanMarks the option as initially selected.
data-keywordsnocomma-separated stringExtra search terms, comma-separated.

template[data-fn="icons"]

Instance-level icon repository.

AttributeRequiredTypeDescription
data-fnyesiconsMarks the template as an icon source (value: icons).
data-reactivenobooleanRe-parses the icons when the template mutates.

* · repeatable

One icon element.

AttributeRequiredTypeDescription
data-keyyesstringIcon key referenced by $icons.

template[data-fn="template"]

Deferred content template mounted by the base class.

AttributeRequiredTypeDescription
data-fnyestemplateMarks the template for deferred mounting (value: template).
data-reactivenobooleanRe-parses the template when it mutates.

Keyboard

KeysActionWhen
Enter SpaceActivates the toggle.—

Accessibility

PartARIADescription
buttonaria-label="${this.getAriaLabel()}" aria-pressed="${this.isActive}"Toggle button with a composed aria-label (base label, value, active suffix — or the switch-to label in toggle mode) and aria-pressed reflecting the active state.
  • The button is a real button with aria-pressed; the label announces the current action in toggle mode.