Skip to content

Radio

A single radio button on a native <input type="radio">, grouped by name — for hand-laid-out radios. For a managed set, use Radio Group.

<script>
import Radio from "@invisible-ui/svelte/Radio.svelte";
</script>

In Elements, the children are the label. The checked property reads the live state, and choosing a radio sends a bubbling change event with detail.value:

<fieldset>
<legend>Plan</legend>
<ds-radio name="plan" value="free" checked>Free</ds-radio>
<ds-radio name="plan" value="pro">Pro</ds-radio>
</fieldset>
PropTypeDefaultDescription
value *string—This radio's value.
name *string—Group name (shared across radios).
checkedbooleanfalseWhether this radio is selected.
disabledbooleanfalseDisable this radio.
labelstring | undefinedundefinedVisible label (or pass it as children).
onChange((value: string) => void) | undefinedundefinedCalled when this radio is chosen.
  • A native <input type="radio">, so grouping and keyboard behaviour are the platform’s.
<Radio name="plan" value="pro" label="Pro" checked />

In React, checked sets the radio’s state and onChange reports its value when the user chooses it. The radios of one name share the choice through the browser:

<Radio name="plan" value="free" label="Free" checked={plan === "free"} onChange={setPlan} />
<Radio name="plan" value="pro" label="Pro" checked={plan === "pro"} onChange={setPlan} />

Themeable via --ds-radio-*.