Svelte Radio - Bitblue

Get started with the radio component to let the user choose a single option from multiple options in the form of a circle based on multiple styles and colors

The radio component lets the user choose a single option from a group, with multiple styles, variants, and colors.

For validated forms, use FormRadio inside a parent Form. FormRadio requires Form context. Use multiple FormRadios with the same name.

Setup

<script>
	import { Radio } from '.';
</script>

Radio examples

<script>
	import { Radio } from '.';
	let selectedValue = $state('2');
</script>

<Radio name="example1" value="1" bind:group={selectedValue}>Default radio</Radio>
<Radio name="example1" value="2" bind:group={selectedValue}>Checked state</Radio>

Disabled state

<script>
	import { Radio } from '.';
	let selectedValue = $state('2');
</script>

<Radio name="disabled-state" disabled value="1" bind:group={selectedValue}>Disabled radio</Radio>
<Radio name="disabled-state" disabled value="2" bind:group={selectedValue}>Disabled checked</Radio>

Alternative syntax

<script>
	import {
		Radio,
		Table,
		TableHead,
		TableHeadCell,
		TableBody,
		TableBodyCell,
		TableBodyRow,
		Label
	} from '.';
</script>

<Table>
	<TableHead>
		<TableHeadCell>Left column</TableHeadCell>
		<TableHeadCell>Right column</TableHeadCell>
	</TableHead>
	<TableBody class="divide-y dark:divide-gray-700">
		<TableBodyRow class="divide-x rtl:divide-x-reverse dark:divide-gray-700">
			<TableBodyCell><Label for="radio1">Default radio</Label></TableBodyCell>
			<TableBodyCell><Label for="radio2">Disabled radio</Label></TableBodyCell>
		</TableBodyRow>
		<TableBodyRow class="divide-x rtl:divide-x-reverse dark:divide-gray-700">
			<TableBodyCell><Radio name="separate" id="radio1" /></TableBodyCell>
			<TableBodyCell><Radio name="separate" id="radio2" disabled /></TableBodyCell>
		</TableBodyRow>
	</TableBody>
</Table>

<Label color="red" class="mt-4 flex items-center font-bold italic">
	Label on the other side <Radio name="separate" classes={{ label: 'ms-2' }} />
</Label>

Radio with a link

<script>
	import { Radio } from '.';
</script>

<Radio name="with-link">
	I agree with the
	<a href="/" class="text-primary-600 dark:text-primary-500 ms-1 hover:underline"
		>terms and conditions</a
	>
	.
</Radio>

Helper text

<script>
	import { Radio, Helper } from '.';
</script>

<Radio aria-describedby="helper-radio-text">Free shipping via Bitblue</Radio>
<Helper id="helper-radio-text" class="ps-6"
	>For orders shipped from $25 in books or $29 in other categories</Helper
>

Bordered

<script>
	import { Radio } from '.';
	let selectedValue3 = $state('2');
</script>

<div class="grid grid-cols-2 gap-6">
	<div class="rounded-sm border border-gray-200 dark:border-gray-700">
		<Radio name="bordered" value="1" bind:group={selectedValue3} classes={{ label: 'w-full p-4' }}
			>Default radio</Radio
		>
	</div>
	<div class="rounded-sm border border-gray-200 dark:border-gray-700">
		<Radio name="bordered" value="2" bind:group={selectedValue3} classes={{ label: 'w-full p-4' }}
			>Checked state</Radio
		>
	</div>
</div>

Radio list group

<script>
	import { Radio } from '.';
	let technology = $state('svelte');
</script>

<p class="mb-4 font-semibold text-gray-900 dark:text-white">
	Technology <span class="capitalize">{technology}</span>
</p>
<ul
	class="w-48 divide-y divide-gray-200 rounded-lg border border-gray-200 bg-white dark:divide-gray-600 dark:border-gray-600 dark:bg-gray-800"
>
	<li><Radio classes={{ label: 'p-3' }} bind:group={technology} value="svelte">Svelte</Radio></li>
	<li><Radio classes={{ label: 'p-3' }} bind:group={technology} value="vue js">Vue JS</Radio></li>
	<li><Radio classes={{ label: 'p-3' }} bind:group={technology} value="react">React</Radio></li>
	<li><Radio classes={{ label: 'p-3' }} bind:group={technology} value="angular">Angular</Radio></li>
</ul>

Horizontal list group

<script>
	import { Radio } from '.';
</script>

<p class="mb-4 font-semibold text-gray-900 dark:text-white">Identification</p>
<ul
	class="w-full items-center divide-x divide-gray-200 rounded-lg border border-gray-200 sm:flex rtl:divide-x-reverse dark:divide-gray-600 dark:border-gray-600 dark:bg-gray-800"
>
	<li class="w-full"><Radio name="hor-list" classes={{ label: 'p-3' }}>Svelte</Radio></li>
	<li class="w-full"><Radio name="hor-list" classes={{ label: 'p-3' }}>Vue JS</Radio></li>
	<li class="w-full"><Radio name="hor-list" classes={{ label: 'p-3' }}>React</Radio></li>
	<li class="w-full"><Radio name="hor-list" classes={{ label: 'p-3' }}>Angular</Radio></li>
</ul>

Inline layout

<script>
	import { Radio } from '.';
	let inline1 = $state('second');
</script>

<div class="flex gap-3">
	<Radio bind:group={inline1} value="first">Inline 1</Radio>
	<Radio bind:group={inline1} value="second">Inline 2 checked</Radio>
	<Radio bind:group={inline1} value="third">Inline 3</Radio>
	<Radio bind:group={inline1} value="fourth" disabled>Inline disabled</Radio>
</div>

Or use the inline prop:

<script>
	import { Radio } from '.';
	let inline2 = $state('third');
</script>

<Radio bind:group={inline2} inline value="first" class="me-2">Inline 1</Radio>
<Radio bind:group={inline2} inline value="second" class="me-2">Inline 2</Radio>
<Radio bind:group={inline2} inline value="third" class="me-2">Inline checked</Radio>
<Radio bind:group={inline2} inline value="fourth" class="me-2" disabled>Inline disabled</Radio>

Colors

Theme colors: primary, secondary, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose.

<script>
	import { Radio } from '.';
	let colors = $state('text-purple-500');
</script>

<p class="mb-4 font-semibold {colors}">Select color</p>
<div class="flex gap-4">
	<Radio bind:group={colors} color="red" value="text-red-500">Red</Radio>
	<Radio bind:group={colors} color="green" value="text-green-500">Green</Radio>
	<Radio bind:group={colors} color="purple" value="text-purple-500">Purple</Radio>
	<Radio bind:group={colors} color="teal" value="text-teal-500">Teal</Radio>
	<Radio bind:group={colors} color="yellow" value="text-yellow-500">Yellow</Radio>
	<Radio bind:group={colors} color="orange" value="text-orange-500">Orange</Radio>
</div>

Advanced layout

<script>
	import { Radio } from '.';
	import { ArrowRightOutline } from '.-icons';
</script>

<p class="mb-5 text-lg font-medium text-gray-900 dark:text-white">Choose technology:</p>
<div class="grid w-full gap-6 md:grid-cols-2">
	<Radio name="custom" custom>
		<div
			class="dark:peer-checked:text-primary-500 peer-checked:border-primary-600 peer-checked:text-primary-600 inline-flex w-full cursor-pointer items-center justify-between rounded-lg border border-gray-200 bg-white p-5 text-gray-500 hover:bg-gray-100 hover:text-gray-600 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-300"
		>
			<div>
				<div class="w-full text-lg font-semibold">0-50 MB</div>
				<div class="w-full">Good for small websites</div>
			</div>
			<ArrowRightOutline class="ms-3 h-10 w-10" />
		</div>
	</Radio>
	<Radio name="custom" custom>
		<div
			class="dark:peer-checked:text-primary-500 peer-checked:border-primary-600 peer-checked:text-primary-600 inline-flex w-full cursor-pointer items-center justify-between rounded-lg border border-gray-200 bg-white p-5 text-gray-500 hover:bg-gray-100 hover:text-gray-600 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-300"
		>
			<div class="block">
				<div class="w-full text-lg font-semibold">500-1000 MB</div>
				<div class="w-full">Good for large websites</div>
			</div>
			<ArrowRightOutline class="ms-3 h-10 w-10" />
		</div>
	</Radio>
</div>

RadioButton

RadioButton is a radio with Button styling. Use standalone or inside ButtonGroup.

<script lang="ts">
	import { RadioButton, ButtonGroup } from '.';
	import { ListMusicSolid, OrderedListOutline, ListOutline } from '.-icons';

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

<div>
	<RadioButton value="notes" checkedClass="outline-4 outline-primary-500" bind:group={radioGroup}
		><ListMusicSolid class="h-7 w-7" /></RadioButton
	>
	<RadioButton value="numbers" checkedClass="outline-4 outline-primary-500" bind:group={radioGroup}
		><OrderedListOutline class="h-7 w-7" /></RadioButton
	>
	<RadioButton value="bullets" checkedClass="outline-4 outline-primary-500" bind:group={radioGroup}
		><ListOutline class="h-7 w-7" /></RadioButton
	>
</div>

<ButtonGroup>
	<RadioButton
		color="green"
		outline
		value="notes"
		checkedClass="outline-4 outline-green-500"
		bind:group={radioGroup}><ListMusicSolid class="h-7 w-7" /></RadioButton
	>
	<RadioButton
		color="green"
		outline
		value="numbers"
		checkedClass="outline-4 outline-green-500"
		bind:group={radioGroup}><OrderedListOutline class="h-7 w-7" /></RadioButton
	>
	<RadioButton
		color="green"
		outline
		value="bullets"
		checkedClass="outline-4 outline-green-500"
		bind:group={radioGroup}><ListOutline class="h-7 w-7" /></RadioButton
	>
</ButtonGroup>

<p>List style: {radioGroup}</p>

RadioButton style

<script lang="ts">
	import { ButtonGroup, RadioButton } from '.';
	let options = $state();
</script>

<ButtonGroup>
	<RadioButton
		color="amber"
		outline
		checkedClass="outline-4 outline-amber-500"
		name="options"
		value="Option 1"
		bind:group={options}>Option 1</RadioButton
	>
	<RadioButton
		color="blue"
		outline
		checkedClass="outline-4 outline-blue-500"
		name="options"
		value="Option 2"
		bind:group={options}>Option 2</RadioButton
	>
</ButtonGroup>

Accessibility

  • Radios in a group share the same name (or bind:group).
  • Provide visible labels; use aria-describedby with Helper text.
  • Keyboard: arrow keys move within a native radio group.

Props

Radio

PropTypeDefaultDescription
groupT—Bindable selected value for the group
valueT—This option’s value
colortheme color—Accent color token
inputClass / labelClassClassValue—Class overrides
classestheme slots—Slot class overrides
custom / inline / tintedvariants—Layout / tint variants
disabled / name / idnative—HTML input attrs
childrenSnippet—Label / custom content

RadioButton

PropTypeDefaultDescription
groupT—Bindable selected value
valueT—This button’s value
inlineboolean—Inline layout
pill / outline / shadowboolean—Button look
sizeButton size—Button size
colorButton color—Button color
checkedClassClassValue—Extra classes when checked
...restHTML input attrs—Native attrs

FormRadio

FormRadio extends RadioProps with required name, optional label and contextKey. Must be a child of Form.


© 2026 Bitblue is a registered trademark. All Rights Reserved.