Provide a multi-select workflow as a grid of input checkbox elements.

Example: Multi-Checkbox HTML Markup

<multi-checkbox name="check-many-boxes">
<optgroup label="Basic Options">
<option value="foo">Foo</option>
<option value="bar">Bar</option>
<option value="baz">Baz</option>
</optgroup>
<optgroup label="Advanced Options">
<option value="fizz">Fizz</option>
<option value="buzz">Buzz</option>
</optgroup>
</multi-checkbox>

Hierarchy (view full)

Properties

_options: (HTMLOptGroupElement | HTMLOptionElement)[]

Predefined elements which were defined in the original HTML.

_choices: Record<string, string> = {}

An object which maps option values to displayed labels.

_internals: ElementInternals

Attached ElementInternals which provides form handling functionality.

_primaryInput: HTMLElement

The primary input (if any). Used to determine what element should receive focus when an associated label is clicked on.

#checkboxes: HTMLInputElement[]

The checkbox elements used to select inputs

tagName: string = "multi-checkbox"
formAssociated: boolean = true

Declare that this custom element provides form element functionality.

Accessors

  • get form(): HTMLFormElement
  • The form this element belongs to.

    Returns HTMLFormElement

  • get name(): string
  • The input element name.

    Returns string

  • get disabled(): boolean
  • Is this element disabled?

    Returns boolean

  • get editable(): boolean
  • Is this field editable? The field can be neither disabled nor readonly.

    Returns boolean

Methods

  • Mark a choice as selected.

    Parameters

    • value: string

      The value to add to the chosen set

    Returns void

  • Mark a choice as un-selected.

    Parameters

    • value: string

      The value to delete from the chosen set

    Returns void

  • Internal

    Apply key attributes on the containing custom HTML element to input elements contained within it.

    Parameters

    • input: any

    Returns void

  • Protected

    Special handling when the custom element is clicked. This should be implemented to transfer focus to an appropriate internal element.

    Parameters

    • event: PointerEvent

    Returns void

  • Translate an input element into a

    of checkboxes.

    Parameters

    • optgroup: HTMLOptGroupElement

      The originally configured optgroup

    Returns HTMLFieldSetElement

    The created fieldset grouping

  • Build an input

    Parameters

    • option: HTMLOptionElement

      The originally configured option

    Returns HTMLLabelElement

    The created labeled checkbox element

  • Handle changes to a checkbox input, marking the selected option as a chosen value.

    Parameters

    • event: Event

      The change event on the checkbox input element

    Returns void