GitHub

Radio Group

Single-select from an options list; the value is the chosen string. Vertical or horizontal orientation, per-option disabled, Space/Enter selection, pure-CSS dot. The options attribute accepts a JSON string. Emits a composed change event.

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

Preview

<esa-radio-group
  label="Priority"
  options='[{"label":"Low","value":"low"}, …]'
  value="medium"
></esa-radio-group>

Orientation

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

<esa-radio-group label="Priority" orientation="horizontal" options="" value="low"></esa-radio-group>

Sizes

<esa-radio-group label="Extra small" size="xs" orientation="horizontal" options="" value="low"></esa-radio-group>
<esa-radio-group label="Small" size="sm" orientation="horizontal" options="" value="low"></esa-radio-group>
<esa-radio-group label="Medium" size="md" orientation="horizontal" options="" value="medium"></esa-radio-group>
<esa-radio-group label="Large" size="lg" orientation="horizontal" options="" value="high"></esa-radio-group>

Form participation

The selected value is submitted under name. Submitting logs the priority entry.

<form>
  <esa-radio-group label="Priority" name="priority" options="" value="low"></esa-radio-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 | null null The single selected option value.
label string '' Group label rendered above the options.
orientation 'vertical' | 'horizontal' 'vertical' Stacking direction of the options.
size 'xs' | 'sm' | 'md' | 'lg' 'md' Circle and label size.

Events

EventTypeDefaultDescription
change CustomEvent<{ value: string }> Fired when a new option is selected. Composed and bubbling; detail.value is the chosen string.

Accessibility

  • The options container has role="radiogroup" labeled by the group label.
  • Each option has role="radio" with aria-checked and selects 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
--color-primary semantic #46a758 via --color-grass-9
--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