Component API

<radio-cards>

Open live example

Single-select group of full-width cards, each with a label and optional
description — for a handful of meaningfully different choices where the
description matters. For many short, same-shaped options (a color swatch,
a basemap style), use radio-pills instead. Wraps native radio inputs for
keyboard/a11y and fires change rather than relying on form submission.

Install

import "@f-ewald/components/radio-cards.js";

Usage

<radio-cards></radio-cards>
<script type="module">
  const el = document.querySelector("radio-cards");
  el.options = [
    { value: "simple", label: "Simple", description: "Quick-ranking view" },
    { value: "detailed", label: "Detailed", description: "Every section and layer" },
  ];
  el.value = "simple";
  el.addEventListener("change", (e) => console.log(e.detail.value));
</script>

Attributes / properties

PropertyAttributeTypeDefaultDescription
optionsJS property onlyRadioCardOption[][]Options to render, one card each.
valuevaluestring""Currently selected value.
disableddisabledbooleanfalseDisables every native radio in the group.

Events

EventDescription
changeA card was selected; detail: { value }.

Slots

None.

CSS custom properties

Custom property
--ui-border
--ui-focus-ring
--ui-font
--ui-font-size-sm
--ui-font-weight-regular
--ui-font-weight-semibold
--ui-primary
--ui-radius-sm
--ui-surface-muted
--ui-text
--ui-text-muted