Radio Group

A group of radio buttons for single selection from multiple options

Basic Usage

Simple radio group with basic options.

Choose an option

Select one option from the list

Theme Selection

Choose your preferred theme


Code Svelte
1
2<script lang="ts">
3	import { RadioGroup, RadioGroupPrimitives } from "@kareyes/aether";
4
5	type RadioGroupOption = RadioGroupPrimitives.RadioGroupOption;
6	let themeSelection = $state("auto");
7
8	const basicOptions: RadioGroupOption[] = [
9		{ id: "1", label: "Option 1", value: "option1" },
10		{ id: "2", label: "Option 2", value: "option2" },
11		{ id: "3", label: "Option 3", value: "option3" },
12	];
13
14	const themeOptions: RadioGroupOption[] = [
15		{ id: "light", label: "Light", value: "light" },
16		{ id: "dark", label: "Dark", value: "dark" },
17		{ id: "auto", label: "Auto", value: "auto" },
18	];
19</script>
20
21<div class="grid gap-8 md:grid-cols-2">
22	<RadioGroup
23		options={basicOptions}
24		bind:value={themeSelection}
25		label="Choose an option"
26		description="Select one option from the list"
27	/>
28
29	<RadioGroup
30		options={themeOptions}
31		bind:value={themeSelection}
32		label="Theme Selection"
33		description="Choose your preferred theme"
34		onValueChange={(val) => console.log('Theme changed:', val)}
35	/>
36</div>

With Descriptions

Radio options with descriptive text for additional context.

Subscription Plan

Select your pricing tier

$0/month - Basic features

$29/month - Advanced features

$99/month - Full features

Notification Preferences

How would you like to be notified?

Receive notifications via email

Receive notifications via text message

Receive push notifications

Don't receive notifications


Code Svelte
1
2<script lang="ts">
3	import { RadioGroup, RadioGroupPrimitives } from "@kareyes/aether";
4	type RadioGroupOption = RadioGroupPrimitives.RadioGroupOption;
5
6	let selectedPlan = $state("pro");
7	let notificationPreference = $state("email");
8
9	const planOptions: RadioGroupOption[] = [
10		{ id: "free", label: "Free", value: "free", description: "$0/month - Basic features" },
11		{ id: "pro", label: "Pro", value: "pro", description: "$29/month - Advanced features" },
12		{ id: "enterprise", label: "Enterprise", value: "enterprise", description: "$99/month - Full features" },
13	];
14
15	const notificationOptions: RadioGroupOption[] = [
16		{ id: "email", label: "Email", value: "email", description: "Receive notifications via email" },
17		{ id: "sms", label: "SMS", value: "sms", description: "Receive notifications via text message" },
18		{ id: "push", label: "Push", value: "push", description: "Receive push notifications" },
19		{ id: "none", label: "None", value: "none", description: "Don't receive notifications", disabled: true },
20	];
21</script>
22
23<div class="grid gap-8 md:grid-cols-2">
24	<RadioGroup
25		options={planOptions}
26		bind:value={selectedPlan}
27		label="Subscription Plan"
28		description="Select your pricing tier"
29		radioSize="lg"
30	/>
31
32	<RadioGroup
33		options={notificationOptions}
34		bind:value={notificationPreference}
35		label="Notification Preferences"
36		description="How would you like to be notified?"
37	/>
38</div>

Orientations

Vertical and horizontal layout options.

Vertical (Default)

Vertical Layout

Horizontal

Horizontal Layout

Code Svelte
1
2<RadioGroup
3	options={basicOptions}
4	bind:value={themeSelection}
5	orientation="vertical"
6	label="Vertical Layout"
7/>
8
9<RadioGroup
10	options={themeOptions}
11	bind:value={themeSelection}
12	orientation="horizontal"
13	label="Horizontal Layout"
14/>

Sizes

Available radio button size options.

Small Radio
Default Radio
Large Radio

Code Svelte
1
2<div class="grid gap-8 md:grid-cols-3">
3	<RadioGroup
4		options={basicOptions.slice(0, 2)}
5		value="option1"
6		radioSize="sm"
7		label="Small Radio"
8	/>
9
10	<RadioGroup
11		options={basicOptions.slice(0, 2)}
12		value="option1"
13		radioSize="default"
14		label="Default Radio"
15	/>
16
17	<RadioGroup
18		options={basicOptions.slice(0, 2)}
19		value="option1"
20		radioSize="lg"
21		label="Large Radio"
22	/>
23</div>

Variants

Color variants for different semantic meanings.

Default Variant
Destructive Variant
Success Variant
Warning Variant

Code Svelte
1
2<div class="grid gap-8 md:grid-cols-2">
3	<RadioGroup options={basicOptions} value="option1" variant="default" label="Default Variant" />
4	<RadioGroup options={basicOptions} value="option1" variant="destructive" label="Destructive Variant" />
5	<RadioGroup options={basicOptions} value="option1" variant="success" label="Success Variant" />
6	<RadioGroup options={basicOptions} value="option1" variant="warning" label="Warning Variant" />
7</div>

Error States

Validation error display with radio groups.

Required Selection

Please select an option

Plan Selection (Error)

Selection required

$0/month - Basic features

$29/month - Advanced features

$99/month - Full features


Code Svelte
1
2<script lang="ts">
3	import { RadioGroup, RadioGroupPrimitives } from "@kareyes/aether";
4	type RadioGroupOption = RadioGroupPrimitives.RadioGroupOption;
5
6	let errorSelection = $state("");
7</script>
8
9<div class="grid gap-8 md:grid-cols-2">
10	<RadioGroup
11		options={basicOptions}
12		bind:value={errorSelection}
13		label="Required Selection"
14		description="Please select an option"
15		error={!errorSelection}
16		required
17	/>
18
19	<RadioGroup
20		options={planOptions}
21		value=""
22		label="Plan Selection (Error)"
23		description="Selection required"
24		error={true}
25		radioSize="lg"
26	/>
27</div>

With Field Component

Using the Field component for labels, descriptions, and error handling.

Select the plan that fits your needs

$0/month - Basic features

$29/month - Advanced features

$99/month - Full features

How would you like to be notified?

Receive notifications via email

Receive notifications via text message

Receive push notifications

Don't receive notifications

Selected Plan: pro

Notification: email


Code Svelte
1
2<script lang="ts">
3	import { RadioGroup, Field, Badge } from "@kareyes/aether";
4</script>
5
6<div class="grid gap-8 md:grid-cols-2">
7	<Field
8		label="Choose Your Plan"
9		description="Select the plan that fits your needs"
10		required
11	>
12		<RadioGroup options={planOptions} bind:value={selectedPlan} />
13	</Field>
14
15	<Field
16		label="Notification Preference"
17		description="How would you like to be notified?"
18		error={!notificationPreference ? "Please select a notification method" : undefined}
19	>
20		<RadioGroup
21			options={notificationOptions}
22			bind:value={notificationPreference}
23			error={!notificationPreference}
24		/>
25	</Field>
26</div>
27
28<div class="space-y-2">
29	<p class="text-sm text-muted-foreground">
30		Selected Plan: <Badge variant="secondary">{selectedPlan}</Badge>
31	</p>
32	<p class="text-sm text-muted-foreground">
33		Notification: <Badge variant="outline">{notificationPreference}</Badge>
34	</p>
35</div>

Interactive Examples

Live interactive radio group demos.

Theme Selection

Current theme: auto


Code Svelte
1
2<script lang="ts">
3	import { RadioGroup, Badge } from "@kareyes/aether";
4	let themeSelection = $state("auto");
5</script>
6
7<div class="space-y-4">
8	<h3 class="text-lg font-medium">Theme Selection</h3>
9	<p class="text-sm text-muted-foreground">
10		Current theme: <Badge variant="outline">{themeSelection}</Badge>
11	</p>
12	<RadioGroup
13		options={themeOptions}
14		bind:value={themeSelection}
15		orientation="horizontal"
16	/>
17</div>

Disabled State

Radio group in disabled state.

Disabled Radio Group

This group is disabled


Code Svelte
1
2<RadioGroup
3	options={basicOptions}
4	value="option2"
5	label="Disabled Radio Group"
6	description="This group is disabled"
7	disabled
8/>

Card Style

Use the card style for more prominent selections with clickable cards.

Cluster Type Selection

Select Cluster Type

Choose how you want to run your workloads

Selected: kubernetes

Subscription Plans (Card Style)

Choose Your Plan

Select the plan that best fits your needs

Selected: pro


Code Svelte
1
2<script lang="ts">
3	import { RadioGroup, Badge, RadioGroupPrimitives } from "@kareyes/aether";
4	type RadioGroupOption = RadioGroupPrimitives.RadioGroupOption;
5
6	let clusterType = $state("kubernetes");
7
8	const clusterOptions: RadioGroupOption[] = [
9		{ id: "kubernetes", label: "Kubernetes", value: "kubernetes", description: "Run GPU workloads on a K8s configured cluster." },
10		{ id: "vm", label: "Virtual Machine", value: "vm", description: "Access a VM configured cluster to run GPU workloads." },
11	];
12</script>
13
14<RadioGroup
15	options={clusterOptions}
16	bind:value={clusterType}
17	label="Select Cluster Type"
18	description="Choose how you want to run your workloads"
19	isCard={true}
20	radioSize="lg"
21/>
22<p class="text-sm text-muted-foreground">
23	Selected: <Badge variant="secondary">{clusterType}</Badge>
24</p>

Card Style vs Regular

Comparison between card style and regular radio group layouts.

Regular Style

Cluster Type

Regular radio button layout

Run GPU workloads on a K8s configured cluster.

Access a VM configured cluster to run GPU workloads.

Card Style

Cluster Type

Card-based layout (clickable cards)


Code Svelte
1
2<div class="grid gap-8 md:grid-cols-2">
3	<div>
4		<h3 class="text-lg font-medium mb-4">Regular Style</h3>
5		<RadioGroup
6			options={clusterOptions}
7			value="kubernetes"
8			label="Cluster Type"
9			description="Regular radio button layout"
10			isCard={false}
11		/>
12	</div>
13
14	<div>
15		<h3 class="text-lg font-medium mb-4">Card Style</h3>
16		<RadioGroup
17			options={clusterOptions}
18			value="kubernetes"
19			label="Cluster Type"
20			description="Card-based layout (clickable cards)"
21			isCard={true}
22		/>
23	</div>
24</div>

Card Style with Variants

Card-style radio groups with color variants.

Success Variant
Warning Variant

Code Svelte
1
2<div class="grid gap-8 md:grid-cols-2">
3	<RadioGroup
4		options={cardPlanOptions.slice(0, 2)}
5		value="pro"
6		label="Success Variant"
7		isCard={true}
8		variant="success"
9	/>
10
11	<RadioGroup
12		options={[
13			{ id: "soft-del", label: "Soft Delete", value: "soft", description: "Move items to trash (recoverable)" },
14			{ id: "perm-del", label: "Permanent Delete", value: "permanent", description: "Delete permanently (cannot be undone)" },
15		]}
16		value="soft"
17		label="Warning Variant"
18		isCard={true}
19		variant="warning"
20	/>
21</div>