Skip to content

HyMenuItemCheckbox ​

Usage examples on this page are written for Lit / plain HTML (<hy-menu-item-checkbox>). The same component ships as HyMenuItemCheckbox in @whitespaceux/harmony-react (native React 19), with typed wrappers for Angular, Solid, Svelte, and Vue. The API reference below applies to all frameworks.

Used inside <hy-menu> — it only means something as part of it.

A checkable row inside an hy-menu. Composition wrapper around hy-menu-item that adds checked / indeterminate state, a leading check/minus glyph, and a change event.

Follows the same composition pattern as hy-color-slider → hy-slider: this element renders an inner hy-menu-item, forwards base props, listens to its select event to toggle state, and publishes its own change event. The inner select continues bubbling so the parent hy-menu sees the composite as the selected item (target retargeting).

The check/minus glyph is the row's own (the icon family of the design system). Checked/indeterminate state is also announced via aria-checked on the item's button.

When not to use

  • Exactly one option of a set active at a time: hy-menu-item-radio, with the same name on each.
  • A row that runs a command or navigates: hy-menu-item.
  • An option a form submits: hy-checkbox in the form.

Accessibility: your part ​

  • Put related checkbox items in an hy-menu-group with a label, so the set is announced as one setting.
  • Label the item with the option it turns on ("Word wrap"), not with an action ("Toggle word wrap").

Examples ​

Checkable view options inside a menu group ​

html
<hy-menu-group label="View">
  <hy-menu-item-checkbox value="word-wrap" label="Word wrap" checked></hy-menu-item-checkbox>
  <hy-menu-item-checkbox value="minimap" label="Minimap"></hy-menu-item-checkbox>
</hy-menu-group>

Reacting to state changes ​

html
<hy-menu-item-checkbox value="word-wrap" label="Word wrap"></hy-menu-item-checkbox>
<script>
  document.querySelector('hy-menu-item-checkbox').addEventListener('change', (e) => {
    console.log(e.detail.checked, e.detail.value);
  });
</script>

API ​

Properties ​

PropertyAttributeTypeDefaultDescription
checkedcheckedbooleanfalseChecked state.
indeterminateindeterminatebooleanfalseIndeterminate state — renders a minus glyph.
valuevaluestring''Identifier used in select / change events.
labellabelstring''Label text. When empty, the default slot is rendered.
descriptiondescriptionstring''A second line under the label — forwarded to the inner hy-menu-item.
shortcutshortcutstring''Keyboard shortcut hint.
disableddisabledbooleanfalseDisables the item — skipped in keyboard nav, no activation.
variantvariant'default' | 'danger''default'Visual variant — danger paints destructive coloring.
sizesize'small' | 'medium''medium'Density variant, forwarded to the inner hy-menu-item. Inside an hy-menu the menu's size wins (it writes this property).
activeactivebooleanfalseWhether this item currently owns the tab stop in its menu's roving tabindex. Reflected so the modal focus trap can match hy-menu-item-checkbox[active]. Managed by the parent hy-menu.

Events ​

EventDetailDescription
change—{ checked, indeterminate, value, reason } when the checked state changes.
select—Relayed from inner hy-menu-item; target retargets to this composite.

Slots ​

SlotDescription
trailingTrailing indicator / shortcut hint.

CSS Custom Properties ​

The documented hooks. Every override hook the component reads — one per token it paints — is listed in @whitespaceux/harmony/theme-api.json, and @whitespaceux/harmony/component-bindings.json (the Harmony MCP get-bindings tool) says which part and state each one paints.

PropertyDefaultDescription
--hy-menu-item-checkbox-foreground-brand-restvar(--hy-foreground-brand-rest)Glyph color in the rest state.
--hy-menu-item-checkbox-foreground-default-disabledvar(--hy-foreground-default-disabled)Glyph color when the host is disabled.

Methods ​

focus() ​

Imperative focus — forwards to the inner hy-menu-item.

setTabIndex() ​

Called by parent hy-menu roving-tabindex logic. Forwards to the inner hy-menu-item and mirrors the tab-stop state on the host's reflected [active] attribute (focus trap discovery + CSS hook).

Built with Lit. Documented with VitePress.