Selection
Radio
MD3 radio button.
import { Radio } from 'omaris' Examples
Group
RadioGroup is the fieldset: it carries the legend, the name and the helper line, so the radios inside only need a value and a label.
<script lang="ts"> import { Radio, RadioGroup } from 'omaris'; let speed = $state('standard');</script><RadioGroup label="Delivery" bind:value={speed} supportingText="Charged at checkout."> <Radio value="standard" label="Standard" description="3–5 working days, free" /> <Radio value="express" label="Express" description="Next day, 5,000 IQD" /> <Radio value="pickup" label="Collect in store" description="Ready in an hour" /></RadioGroup> Horizontal and states
Horizontal suits a short set of short labels, and nothing else.
<script lang="ts"> import { Radio, RadioGroup } from 'omaris'; let size = $state('m');</script><div class="flex w-full flex-col gap-8"> <RadioGroup label="Size" orientation="horizontal" bind:value={size}> <Radio value="s" label="S" /> <Radio value="m" label="M" /> <Radio value="l" label="L" /> </RadioGroup> <RadioGroup label="Invalid" invalid supportingText="Pick a plan to continue." value=""> <Radio value="free" label="Free" /> <Radio value="pro" label="Pro" /> </RadioGroup> <RadioGroup label="Disabled" disabled value="a"> <Radio value="a" label="Not changeable" /> <Radio value="b" label="Nor this" /> </RadioGroup></div> When to use it
Use it for
- One of two to seven options, all visible: a plan, a shipping method, a delivery day.
RadioGroupcarries the legend,name,valueandsupportingText. EachRadioneeds only avalueand alabel. - Options that need a line of explanation. Put it in
descriptionon each radio. - A required question. Set
requiredandinvalidon the group and put the reason insupportingText; it turns red and is announced. - A short set of short labels, like Yes/No or S/M/L. Use
orientation="horizontal", and nothing longer.
Do
- Give every group a
label. It is the fieldset's legend, read before each option. - Bind
valueon the group, notgroupon each radio. Inside aRadioGroupa radio takes its name, tone and size from it.bind:groupis for a radio on its own. - Preselect the default when the form has one. Leave it empty only when the person must choose, and mark the group
required. - Put the most common option first, not the cheapest or the alphabetical one.
Don't
- Use bare
Radios without aRadioGroupunless you build your own fieldset. You lose the legend, the helper line and the sharednamethat lets arrow keys move between them. - Disable an option to say it is unavailable. Explain in
description, or drop it. - Write labels as sentences. Keep them short and put detail in
description.
Quick reference
tone Radioprimary(default)secondarytertiarydestructivesuccesswarninginfo
size Radiosmmd(default)lg
orientation RadioGroupvertical(default)horizontal
API
Radio
MD3 radio button.
Inside a <RadioGroup> it takes its name, value binding, tone and size from the group. On its own it works as a plain controlled radio — bind group the way you would with Svelte's own bind:group.
The dot scales in from nothing rather than appearing, which is the detail that makes a radio feel like MD3 rather than a browser default.
import { Radio } from 'omaris' Parts
Every element this renders is reachable from outside. Pass Tailwind for one part as classes={{ part: '…' }}; class covers the root and is merged last, so it always wins.
root- No description in the source yet.
control- No description in the source yet.
circle- The ring.
dot- The filled center, scaled from 0 when unselected.
input- No description in the source yet.
label- No description in the source yet.
description- No description in the source yet.
Props
value required string This radio's value. Required — it's what the group selects.
group bindableDefaults to undefined
string | undefined The selected value, when the radio is used outside a group. Bindable.
tone RadioTone primarysecondarytertiarydestructivesuccesswarninginfo
size RadioSizeToken smmdlg
label string description string invalid boolean haptics Defaults to true
boolean A haptic tap when it's picked. Follows the shared haptics store; false opts this radio out.
sound Defaults to true
boolean A sound cue when it's picked. Follows the shared sound store; false opts this radio out.
class string classes RadioClasses Per-part Tailwind overrides. class still covers the root.
children Snippet ref bindableDefaults to null
HTMLInputElement | null RadioGroup
The fieldset around a run of radios: legend, the options, a helper line.
import { RadioGroup } from 'omaris' Parts
Every element this renders is reachable from outside. Pass Tailwind for one part as classes={{ part: '…' }}; class covers the root and is merged last, so it always wins.
root- No description in the source yet.
label- The group heading, rendered as the fieldset's legend.
options- Where the radios sit.
support- No description in the source yet.
Props
value bindableDefaults to undefined
string Selected value. Bindable.
name string Shared name for the radios. Generated when omitted.
orientation Defaults to 'vertical'
'vertical' | 'horizontal' verticalhorizontal
tone Defaults to 'primary'
Tone size Defaults to 'md'
RadioSize disabled boolean Inside a Field, defaults to the field's.
required boolean Inside a Field, defaults to the field's.
invalid boolean Inside a Field, defaults to the field's.
label string Group heading, rendered as the fieldset's legend.
supportingText string Helper line under the group. Turns red when invalid.
class string classes RadioGroupClasses Per-part Tailwind overrides. class still covers the root.
children Snippet