GitHub

Radio Group

llms.txt

Example

Selected: comfortable

With descriptions

Free forever. Great for small side projects.
$12/month. Unlimited projects and team seats.
Custom pricing with SSO and priority support.

Plan: pro

Usage

A set of radio buttons where exactly one can be selected at a time.

The simplest way is to pass an options array — items, labels, and spacing are handled for you:

		
<script lang="ts">
	import { RadioGroup } from '@foxui/all';

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

<RadioGroup
	bind:value
	options={[
		{ value: 'default', label: 'Default' },
		{ value: 'comfortable', label: 'Comfortable' },
		{ value: 'compact', label: 'Compact' }
	]}
/>

With descriptions

Each option can carry an optional description:

		
<RadioGroup
	bind:value
	options={[
		{ value: 'card', label: 'Card', description: 'Pay with a credit or debit card.' },
		{ value: 'paypal', label: 'PayPal', description: 'Redirect to PayPal to complete payment.' }
	]}
/>

Horizontal layout

		
<RadioGroup bind:value orientation="horizontal" options={[...]} />

Custom rendering

For full control, skip options and compose with RadioGroupItem:

		
<script lang="ts">
	import { RadioGroup, RadioGroupItem, Label } from '@foxui/all';

	let value = $state('option-one');
</script>

<RadioGroup bind:value>
	<label class="flex items-center gap-2">
		<RadioGroupItem value="option-one" id="option-one" />
		<Label for="option-one">Option One</Label>
	</label>
	<label class="flex items-center gap-2">
		<RadioGroupItem value="option-two" id="option-two" />
		<Label for="option-two">Option Two</Label>
	</label>
</RadioGroup>

API Reference

RadioGroup

A set of radio buttons where exactly one can be selected. Pass an `options` array for the common case, or use `RadioGroupItem` as children for custom layouts.

Property
value
options
variant
sizeVariant
orientation
disabled
onValueChange
children
class

RadioGroupItem

A single radio item. Use when composing a custom layout.

Property
value
variant
sizeVariant
disabled
id
class