navigationhwc
z-lshTheme Toggle
Button that applies a theme/group value as a class on the document root, persisted in localStorage and synced across instances.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
value | string | '' | Value applied to the group when clicked (e.g. dark, light, or a theme class like theme-ocean). |
group | string | '' | Configuration group the value belongs to; mode is special-cased to toggle the dark class on <html>. |
prevent-autoupdate | boolean | false | Opts out of listening to other instances' z-lsh:change events. |
toggle | boolean | false | In the mode group, flips between dark and light instead of applying a fixed value. |
Inherited from Hwc
| Attribute | Type | Default | Description |
|---|---|---|---|
i18n | string | '' | Per-instance text overrides as key: text pairs, merged over the global z-i18n script and the built-in defaults. |
floating | string | '' | Floating UI placement options (for example offset and shiftPadding) parsed as key: value pairs. |
force-prevent-rerender | boolean | false | Skips re-rendering after the first render; an existing data-host-inner child is adopted as the rendered DOM. |
template | string | '' | 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
| Attribute | Type | Default | Description |
|---|---|---|---|
cls | string | '' | Adds classes to named parts as key: classes pairs; a plain string targets the default part. |
stl | string | '' | 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
| Key | Default class | cls | stl | Description |
|---|---|---|---|---|
button | z-lsh | yes | yes | The toggle button (default z-lsh); the default cls/stl target. Receives z-active while its value is active. |
i18n Keys
| Key | Default | Placeholders | Description |
|---|---|---|---|
active-label | Active | — | Suffix appended when the value is active. |
aria-label | Toggle theme | — | Base accessible label of the button. |
switch-to-dark | Switch to dark mode | — | Toggle-mode label suffix when currently light. |
switch-to-light | Switch to light mode | — | Toggle-mode label suffix when currently dark. |
Events
| Event | Detail | Flags | Description |
|---|---|---|---|
z-lsh:before-change | { group: string; value: string; previousValue: string; config: { [group: string]: string; } } | cancelable, bubbles | Cancelable; fires before applying a value. Detail: group, value, previousValue, config. |
z-lsh:change | { group: string; value: string; previousValue: string; config: { [group: string]: string; } } | bubbles | Fires after a value is applied and persisted, with the same detail; other instances sync from it. |
Data Hooks
| Attribute | Values | Applies to | Role | Description |
|---|---|---|---|---|
data-host-inner · from Hwc | — | descendant | config | Marks the rendered inner wrapper so force-prevent-rerender can adopt server-rendered DOM without re-rendering. |
data-reactive · from Hwc | — | descendant | config | Opts 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).
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | config | Marks the script as configuration (value: config). |
data-reactive | no | boolean | Re-parses the configuration when the script mutates. |
select[data-fn="data-source"]
Hidden select parsed into grouped option data by the base class.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | data-source | Marks the select as the data source (value: data-source). |
data-reactive | no | boolean | Re-parses the options when the select mutates. |
optgroup · repeatable
Groups options under a label.
| Attribute | Required | Type | Description |
|---|---|---|---|
label | yes | string | Group header text; also the default group key. |
disabled | no | boolean | Disables every option in the group. |
data-key | no | string | Overrides the group key used in the parsed data. |
data-keywords | no | comma-separated string | Comma-separated keywords stored with the group's data. |
option · repeatable
One option entry within the group.
| Attribute | Required | Type | Description |
|---|---|---|---|
value | no | string | Value carried by this option in the parsed data. |
disabled | no | boolean | Makes the option non-selectable. |
selected | no | boolean | Marks the option as initially selected. |
data-keywords | no | comma-separated string | Extra search terms, comma-separated; searched alongside the label and value. |
option · repeatable
One ungrouped option entry.
| Attribute | Required | Type | Description |
|---|---|---|---|
value | no | string | Value carried by this option in the parsed data. |
disabled | no | boolean | Makes the option non-selectable. |
selected | no | boolean | Marks the option as initially selected. |
data-keywords | no | comma-separated string | Extra search terms, comma-separated. |
template[data-fn="icons"]
Instance-level icon repository.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | icons | Marks the template as an icon source (value: icons). |
data-reactive | no | boolean | Re-parses the icons when the template mutates. |
* · repeatable
One icon element.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-key | yes | string | Icon key referenced by $icons. |
template[data-fn="template"]
Deferred content template mounted by the base class.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | template | Marks the template for deferred mounting (value: template). |
data-reactive | no | boolean | Re-parses the template when it mutates. |
Keyboard
| Keys | Action | When |
|---|---|---|
| Enter Space | Activates the toggle. | — |
Accessibility
| Part | ARIA | Description |
|---|---|---|
button | aria-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
buttonwitharia-pressed; the label announces the current action in toggle mode.