Forms

Radio group

Chooses exactly one option from a short list.

Installation

npx sinaui add radio

Examples

Basic

Reading room
<script lang="ts">
	import * as Radio from '#lib/ui/radio/index.js';

	let room = $state('baghdad');
</script>

<Radio.Group legend="Reading room" bind:value={room}>
	<Radio.Item value="baghdad">Bayt al-Hikma, Baghdad</Radio.Item>
	<Radio.Item value="cordoba">Library of Córdoba</Radio.Item>
	<Radio.Item value="fez">Al-Qarawiyyin, Fez</Radio.Item>
</Radio.Group>

With hints

Each hint is read out with its option. Disabled options stay visible so people know they exist.

How should we copy it?
Hand-copied on paper from the Samarkand mills.
With gold leaf and lapis. Takes a season.
The key chapters only.
<script lang="ts">
	import * as Radio from '#lib/ui/radio/index.js';

	let copy = $state('scribe');
</script>

<Radio.Group legend="How should we copy it?" bind:value={copy}>
	<Radio.Item value="scribe" hint="Hand-copied on paper from the Samarkand mills."
		>Scribe</Radio.Item
	>
	<Radio.Item value="illuminated" hint="With gold leaf and lapis. Takes a season.">
		Illuminated
	</Radio.Item>
	<Radio.Item value="summary" hint="The key chapters only." disabled>Summary</Radio.Item>
</Radio.Group>

Horizontal

For two or three short options. Arrow keys still move in reading order.

Script
<script lang="ts">
	import * as Radio from '#lib/ui/radio/index.js';

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

<Radio.Group legend="Script" orientation="horizontal" bind:value={script}>
	<Radio.Item value="kufic">Kufic</Radio.Item>
	<Radio.Item value="naskh">Naskh</Radio.Item>
	<Radio.Item value="thuluth">Thuluth</Radio.Item>
</Radio.Group>

Hint and error

Both belong to the whole group and are read with its question.

Script for the copy

The copyist can write in one script per manuscript.

Choose a script for the copy.

<script lang="ts">
	import * as Radio from '#lib/ui/radio/index.js';

	let script = $state<string>();
</script>

<Radio.Group
	legend="Script for the copy"
	bind:value={script}
	required
	hint="The copyist can write in one script per manuscript."
	error={script ? undefined : 'Choose a script for the copy.'}
>
	<Radio.Item value="muhaqqaq">Muhaqqaq</Radio.Item>
	<Radio.Item value="rayhani">Rayhani</Radio.Item>
	<Radio.Item value="tawqi">Tawqi‘</Radio.Item>
</Radio.Group>

Props

Radio.Group

PropTypeDefault
legendstring (required)
valuestring, bindable
namestringa unique id
orientation'vertical' | 'horizontal''vertical'
disabledbooleanfalse
requiredbooleanfalse
hintstring
errorstring

Radio.Item

PropTypeDefault
valuestring (required)
hintstring
disabledbooleanfalse

Accessibility

  • A <fieldset> with a <legend>: screen readers announce the question with each option.
  • Native radios: the group is one Tab stop, and arrow keys move and select.
  • Each group gets a unique name by default, so two groups on a page never merge.
KeyAction
TabMoves into the group at the selected option.
↓ / →, ↑ / ←Selects the next / previous option.
SpaceSelects the focused option if none is selected.
Introduction
Theming
Changelog
Button
Action button
Confirm button
Copy button
Hold to confirm
Split button
Calendar
Checkbox
Color picker
Combobox
Date picker
Date range picker
File drop
Form
Input
Mention input
Multi select
Number field
OTP input
Password input
Phone input
Radio cards
Radio group
Rich text editor
Search field
Segmented control
Select
Signature pad
Slider
Switch
Tag input
Upload
Wheel picker
Textarea
Time field
Toggle group
Toolbar
Alert dialog
Command palette
Context menu
Dialog
Drawer
Dropdown
Hover card
Popover
Tooltip
Announcement bar
Alert
Empty state
Meter
Progress
Rolling number
Skeleton
Spinner
Toast
Avatar
Avatar group
Badge
Card
Carousel
Chart
Chat
Code block
Data table
Folder
Kbd
Mind map
Resizable panels
Scroll area
Separator
Sortable
Table
Tag group
Virtual list
Audio player
Image
Image compare
Video
Visualizer
Breadcrumb
File tree
Menubar
Navigation menu
Pagination
Sidebar layout
Stepper
Tabs
Alarm clock
Clock
Dynamic island
Fluid orb
Hourglass
Stopwatch
Timer
AI chat
AI media
Auth
Board
Booking
Dashboard
File explorer
Messaging
Notifications
Settings
Team
Overview
Pricing
Agent chat
Calendar
Voice agent
Mail inbox
CMS
Blog
Marketing site
E-commerce
AI agents
SaaS landing page
SaaS app
Accordion
Dark theme
Light theme