Forms

RadioGroup

A group of radio buttons for single selection. Supports list/card variants, horizontal/vertical orientation, legend, descriptions, and controlled state.

Playground

Experiment with different props in real-time.

Choose plan

Basic Usage

Pass items and use bind:value.

<script lang="ts">
  import { RadioGroup } from 'sv5ui';

  let plan = $state('standard');

  const plans = [
    { value: 'starter', label: 'Starter' },
    { value: 'standard', label: 'Standard' },
    { value: 'premium', label: 'Premium' }
  ];
</script>

<RadioGroup items={plans} bind:value={plan} />

With Descriptions

Add per-item descriptions.

Delivered within 1-2 business days

Delivered within 3-5 business days

Delivered within 7-10 business days

<RadioGroup items={[
  { value: 'express', label: 'Express', description: 'Delivered within 1-2 business days' },
  { value: 'standard', label: 'Standard', description: 'Delivered within 3-5 business days' },
  { value: 'economy', label: 'Economy', description: 'Delivered within 7-10 business days' }
]} bind:value />

Variants

2 visual styles.

List
Card
Starter
Standard
Premium
<!-- List variant (default) -->
<RadioGroup variant="list" legend="List" {items} bind:value />

<!-- Card variant -->
<RadioGroup variant="card" legend="Card" {items} bind:value />

Indicator Position

Control where the radio indicator appears.

Start
End
Hidden
<RadioGroup indicator="start" legend="Start" {items} bind:value />
<RadioGroup indicator="end" legend="End" {items} bind:value />
<RadioGroup indicator="hidden" legend="Hidden" {items} bind:value />

Orientation

Vertical or horizontal layout.

Vertical
Horizontal
<!-- Vertical (default) -->
<RadioGroup orientation="vertical" {items} bind:value />

<!-- Horizontal -->
<RadioGroup orientation="horizontal" {items} bind:value />

Sizes

5 sizes.

XS
SM
MD
LG
XL
<RadioGroup size="xs" {items} bind:value />
<RadioGroup size="sm" {items} bind:value />
<RadioGroup size="md" {items} bind:value />
<RadioGroup size="lg" {items} bind:value />
<RadioGroup size="xl" {items} bind:value />

Colors

8 semantic color schemes.

Primary
Success
Warning
Error
<RadioGroup color="primary" {items} bind:value />
<RadioGroup color="success" {items} bind:value />
<RadioGroup color="warning" {items} bind:value />
<RadioGroup color="error" {items} bind:value />

Legend

Add an accessible legend with legend and required.

Choose your plan
<RadioGroup items={plans} bind:value legend="Choose your plan" required />

Disabled

Disable entire group or individual items.

All disabled
Individual disabled
<!-- Disable entire group -->
<RadioGroup disabled {items} bind:value />

<!-- Disable individual items -->
<RadioGroup items={[
  { value: 'free', label: 'Free' },
  { value: 'pro', label: 'Pro' },
  { value: 'enterprise', label: 'Enterprise', disabled: true }
]} bind:value />

Loading

Show spinner state.

<RadioGroup loading {items} bind:value />

Card Grid

Combine card variant with horizontal orientation.

Select a plan
Free

5GB storage, basic features

Pro

50GB storage, advanced analytics

Team

Unlimited storage, collaboration

<RadioGroup
  variant="card"
  orientation="horizontal"
  legend="Select a plan"
  items={[
    { value: 'free', label: 'Free', description: '5GB storage, basic features' },
    { value: 'pro', label: 'Pro', description: '50GB storage, advanced analytics' },
    { value: 'team', label: 'Team', description: 'Unlimited storage, collaboration' }
  ]}
  bind:value
/>

Controlled

Use bind:value for two-way binding.

Selected: standard

<script lang="ts">
  import { RadioGroup } from 'sv5ui';

  let value = $state('standard');
</script>

<RadioGroup {items} bind:value />
<p>Selected: {value}</p>

UI Slots

Use the ui prop to override classes on internal elements.

SlotDescription
rootOutermost wrapper
fieldsetFieldset wrapping the group
legendLegend element for the fieldset
itemEach radio item row
baseThe radio circle element
containerWrapper around the radio indicator
indicatorInner dot when selected
loadingIconLoading spinner icon
wrapperWraps label and description
labelLabel text
descriptionDescription text

Snippets

SnippetDescription
legendSlotCustom legend rendering
labelSlotCustom label for each item
descriptionSlotCustom description for each item

Props

PropTypeDefault
itemsRadioGroupItem[][]
valuestring''
onValueChange(value) => void-
variant'list' | 'card''list'
indicator'start' | 'end' | 'hidden''start'
orientation'vertical' | 'horizontal''vertical'
colorColorType'primary'
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
legendstring-
loadingbooleanfalse
disabledbooleanfalse
requiredbooleanfalse
loopbooleantrue
namestring-
idstring-
refHTMLElement | nullnull
classstring-
uiRecord<Slot, Class>-

Item Props

PropTypeDefault
valuestring-
labelstring-
descriptionstring-
disabledbooleanfalse