GitHub

Checkbox Group

Multi-select from an options list; the value is a string[]. Vertical or horizontal orientation, per-option disabled, Space/Enter toggling. The options attribute accepts a JSON string. Emits a composed change event.

Stable wc import '@esa/ecology/esa-checkbox-group';

Preview

<esa-checkbox-group
  label="Monitored media"
  options='[{"label":"Air quality","value":"air"}, …]'
  value='["water"]'
></esa-checkbox-group>

Orientation

vertical is the default; switch to horizontal to lay options out in a row.

<esa-checkbox-group label="Monitored media" orientation="horizontal" options=""></esa-checkbox-group>

Sizes

<esa-checkbox-group label="Extra small" size="xs" orientation="horizontal" options=""></esa-checkbox-group>
<esa-checkbox-group label="Small" size="sm" orientation="horizontal" options=""></esa-checkbox-group>
<esa-checkbox-group label="Medium" size="md" orientation="horizontal" options=""></esa-checkbox-group>
<esa-checkbox-group label="Large" size="lg" orientation="horizontal" options=""></esa-checkbox-group>

Form participation

Each selected value is submitted under name. Submitting logs all media entries.

<form>
  <esa-checkbox-group label="Media" name="media" options="" value='["air"]'></esa-checkbox-group>
  <button type="submit">Submit</button>
</form>

API

PropTypeDefaultDescription
options EsaOption[] | string [] Array of {'{ label, value, disabled? }'}, or a JSON string of the same when set as an attribute.
value string[] [] Selected option values.
label string '' Group label rendered above the options.
orientation 'vertical' | 'horizontal' 'vertical' Stacking direction of the options.
size 'xs' | 'sm' | 'md' | 'lg' 'md' Box and label size.
name string '' Field name each selected value is submitted under.

Events

EventTypeDefaultDescription
change CustomEvent<{ value: string[] }> Fired when any option is toggled. Composed and bubbling; detail.value is the current selection array.

Accessibility

  • The options container has role="group" labeled by the group label.
  • Each box has role="checkbox" with aria-checked and toggles on Space or Enter.
  • Disabled options carry aria-disabled and a -1 tabindex.
  • The change event is composed and bubbles, so it can be caught on the host or an ancestor.

Theming surface

Every public token this component reads, extracted from its source at build time. The Resolves to column walks each token's real lineage — component → semantic → primitive → raw value — so you can see exactly where re-pointing it lands. A spoke re-skins by overriding these in its theme-<slug>.css; component internals are never edited. No hook for what you need? File it with /request-lego.

TokenTierResolves to
--focus-ring-color component #65ba74 via --color-border-focus--color-grass-8
--focus-ring-width component 2px
--form-bg component #fcfcfc via --color-surface--color-gray-1
--form-border-color component #cecece via --color-border--color-gray-7
--form-border-color-focus component #65ba74 via --color-border-focus--color-grass-8
--form-border-width component 1px
--form-font-size-lg component clamp(0.875rem, 0.77rem + 0.52vw, 1.125rem) via --type-size-300
--form-font-size-md component clamp(0.75rem, 0.66rem + 0.44vw, 0.9375rem) via --type-size-200
--form-font-size-sm component clamp(0.625rem, 0.56rem + 0.32vw, 0.75rem) via --type-size-100
--form-font-size-xs component clamp(0.5rem, 0.44rem + 0.3vw, 0.625rem) via --type-size-050
--form-radius-lg component 0.5rem via --radius-200
--form-radius-md component 0.5rem via --radius-200
--form-radius-sm component 0.25rem via --radius-100
--form-radius-xs component 0.25rem via --radius-100
--color-primary semantic #46a758 via --color-grass-9
--color-text-inverse semantic #fcfcfc via --color-gray-1
--color-text-primary semantic #202020 via --color-gray-12
--font-sans semantic 'DM Sans', sans-serif
--transition-fast semantic 150ms ease
--font-weight-medium primitive 500
--spacing-200 primitive 0.5rem
--spacing-400 primitive 1rem