Inputs
RadioGroup
Single-selection radio group as a list of rows or a grid of selectable cards.
<script>
import { RadioGroup } from "@codeatlasdev/ui";
let plan = $state("pro");
</script>
<RadioGroup items={[{ value: "free", label: "Free" }, { value: "pro", label: "Pro" }]} bind:value={plan} />
The options are native radio inputs that share one name, so arrow keys move focus and selection inside the group and Tab leaves it. The group has no visible title of its own: pass aria-label, or wrap it in a fieldset with a legend when the choice needs a visible heading.
Vertical
The default layout.
Selected: apple
Reference #037 · Pick in the gallery
Code
Horizontal
orientation="horizontal" lays the options out in a row.
Reference #036 · Pick in the gallery
Code
Cards
variant="cards" renders each option as a selectable card with an optional description.
Reference #034 · Pick in the gallery
Code
Disabled
Disable a single item, or the whole group.
Reference #035 · Pick in the gallery
Code
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | '' | Bindable selected value. |
items | RadioItem[] | – | Options: { value, label, description?, disabled? }. description is shown in the cards variant. |
variant | 'list' | 'cards' | 'list' | list renders radio and label rows. cards renders each option as a card in a responsive grid, and the whole card is the hit area. |
name | string | – | Native name of the radios, so the value is in FormData on a plain form submit (works without JS and with use:enhance). Unset: an internal id groups them and the value is not submitted by name. |
orientation | 'vertical' | 'horizontal' | 'vertical' | Layout direction and arrow-key axis. |
disabled | boolean | false | Disables the entire group. |
aria-label | string | – | Accessible name of the group. |
class | string | – | Extra classes on the group. |
onchange | (value: string) => void | – | Called when the selection changes. |