Forms

Radio cards

A single choice where each option needs a few words to decide: plans, delivery, sizes. The selection glides from card to card.

Installation

npx sinaui add radio-cards

Examples

Side by side

Cards wrap to fit. One can't be chosen right now, and says why.

Membership
<script lang="ts">
	import RadioCards, { type RadioCard } from '#lib/ui/RadioCards.svelte';

	const plans: RadioCard[] = [
		{ value: 'reader', label: 'Reader', description: 'Two loans at a time', detail: 'Free' },
		{
			value: 'scholar',
			label: 'Scholar',
			description: 'Ten loans and a copying desk',
			detail: '12 dinars'
		},
		{
			value: 'circle',
			label: 'Study circle',
			description: 'Eight members, one room',
			detail: '40 dinars'
		},
		{
			value: 'patron',
			label: 'Patron',
			description: 'Your name on a shelf',
			detail: '100 dinars',
			disabled: true,
			reason: 'Opens again after Ramadan'
		}
	];
	let plan = $state('scholar');
</script>

<div class="demo">
	<RadioCards legend="Membership" options={plans} bind:value={plan} name="plan" />
</div>

<style>
	.demo {
		inline-size: min(40rem, 100%);
	}
</style>

One per row, with icons

layout="list" puts the detail at the end of each row.

Send the manuscript
<script lang="ts">
	import { BoatIcon, CamelIcon, HorseIcon } from '@hugeicons/core-free-icons';
	import RadioCards, { type RadioCard } from '#lib/ui/RadioCards.svelte';

	const routes: RadioCard[] = [
		{
			value: 'caravan',
			label: 'By caravan',
			description: 'Baghdad to Damascus, 30 days',
			detail: '4 dinars',
			icon: CamelIcon
		},
		{
			value: 'post',
			label: 'By the barid post',
			description: 'Relay riders, 8 days',
			detail: '15 dinars',
			icon: HorseIcon
		},
		{
			value: 'river',
			label: 'Down the Tigris',
			description: 'To Basra only, 6 days',
			detail: '6 dinars',
			icon: BoatIcon
		}
	];
	let route = $state('caravan');
</script>

<div class="demo">
	<RadioCards legend="Send the manuscript" options={routes} bind:value={route} layout="list" />
</div>

<style>
	.demo {
		inline-size: min(30rem, 100%);
	}
</style>

Props

PropTypeDefault
legendstring (required)
options{ value, label, description?, detail?, icon?, disabled?, reason? }[]
valuestring (bindable)
layout'grid' | 'list''grid'
namestringa unique id
required, disabledbooleanfalse
hint, errorstring

Keyboard

KeyDoes
TabMoves into the group, onto the chosen card
↑ ↓ ← →Chooses the previous or next card
SpaceChooses the focused card

Accessibility

  • Real radios in a fieldset: the legend is read with each card, and forms send the value.
  • Each card's description (or the reason it's unavailable) is read after its name.
  • The chosen card shows a filled mark as well as its color.
  • With reduced motion, the selection moves without gliding.
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