Skip to main content
Urbicon UI

RadioGroup

Radio group for single-option selection.

Playground

Notification preference
Orientation
Variant
Size
<RadioGroup
  intent="primary"
  size="md"
  variant="outlined"
>
  <RadioItem value="all" label="All notifications" />
  <RadioItem value="mentions" label="Mentions only" />
  <RadioItem value="none" label="None" />
</RadioGroup>

01 Purpose

Reach for a RadioGroup to pick exactly one option from a small set, with every choice visible at once.

ControlReach for it when
RadioGroupOne choice from two to about five options, all worth showing at once: a plan, a shipping speed, a payment method.
CheckboxIndependent on/off toggles, or when more than one option can be selected at the same time.
SegmentGroupOne choice from a few short, mutually exclusive options where a compact toggle row reads better than a stacked list.
SelectOne choice from a long list. Showing every option would crowd the layout, so it collapses into a dropdown.

02 Examples

Plan picker with descriptions

Bind the group to a $state variable with bind:value, then read it back to drive the rest of the form. A plain value sets a starting choice without tracking changes, and name sets the key the value submits under.
Choose your plan

Selected: pro

<script>
  let selectedPlan = $state('pro');
</script>

<RadioGroup label="Choose your plan" name="plan" bind:value={selectedPlan}>
  <RadioItem value="free" label="Free" description="3 projects, 1 GB storage, community support" />
  <RadioItem value="pro" label="Pro · $12/mo" description="Unlimited projects, 100 GB, priority support" />
  <RadioItem value="enterprise" label="Enterprise" description="Custom limits, SLA, dedicated account manager" />
</RadioGroup>

Per-item disabled

Disable individual options while the rest of the group stays interactive. Arrow-key navigation skips the disabled item.
Shipping speed
<RadioGroup label="Shipping speed" value="standard">
  <RadioItem value="standard" label="Standard (3–5 days)" />
  <RadioItem value="express" label="Express (1–2 days)" disabled />
  <RadioItem value="overnight" label="Overnight" />
</RadioGroup>

Helper and error

Set helper or error on the group. When both are present, error replaces helper and marks the group aria-invalid.
Frequency
You can change this later in settings
Agreement
<RadioGroup label="Frequency" helper="You can change this later in settings">
  <RadioItem value="daily" label="Daily" />
  <RadioItem value="weekly" label="Weekly" />
</RadioGroup>
<RadioGroup label="Agreement" error="Please select an option to continue">
  <RadioItem value="accept" label="I accept" />
  <RadioItem value="decline" label="I decline" />
</RadioGroup>

03 Customization

Card options via one provider default

A single BlocksProvider default turns every option into a bordered card that tints when selected, so you set the look once instead of repeating slotClasses on each RadioItem.
Region
<BlocksProvider
  defaults={{
    RadioItem: {
      slotClasses: {
        item: 'w-full rounded-contain border border-border-subtle p-3 transition-colors has-[:checked]:border-primary has-[:checked]:bg-primary/10'
      }
    }
  }}
>
  <RadioGroup label="Region" value="eu" slotClasses={{ group: 'gap-2' }}>
    <RadioItem
      value="eu"
      label="EU (Frankfurt)"
      description="GDPR-friendly, lowest latency in Europe"
    />
    <RadioItem
      value="us"
      label="US (Virginia)"
      description="Closest to North American users"
    />
    <RadioItem
      value="apac"
      label="APAC (Singapore)"
      description="Lowest latency across Asia-Pacific"
    />
  </RadioGroup>
</BlocksProvider>

This is one of five ways to restyle a block. See Customization for class, slotClasses, unstyled, preset and provider-level overrides.

04 Accessibility

Built-in ARIA

Every option is a native <input type="radio"> inside a role="radiogroup" container, so a native form submits the selected value and assistive technology reads the group without extra wiring. Set name to control the key it submits under. It is auto-generated otherwise. The group label links via aria-labelledby and helper or error text via aria-describedby. The selected option is marked by a filled dot.

Keyboard

Tab enters the group and lands on the selected item, or on the first item when nothing is selected yet. Tab again leaves the group for the next control. Arrow keys move between options and select as they go: Up/Down for vertical groups, Left/Right for horizontal ones, wrapping at both ends and skipping disabled items. Focus rings use focus-visible:, so they appear only for keyboard navigation.

05 API Reference

21 props
21 props 1 required
Prop
Type
Default
Description

06 Types

Local type definitions used by this component.

14 types
Name
Kind
Category
Used by
Description

07 Installation

Import

import { RadioGroup, RadioItem } from '@urbicon-ui/blocks';