Radio Group
A radio group component that allows users to select a single option from a list. Features smooth transitions, customizable styles, and support for different layouts.
Import
import RadioGroup from "$lib/components/RadioGroup.svelte"; Usage
Examples showing different radio group layouts.
Vertical Layout (Default)
Selected: amazing
Horizontal Layout
Selected: amazing
<script lang="ts">
let value = "amazing";
const options = [
{ id: 'amazing', label: 'Amazing', value: 'amazing' },
{ id: 'average', label: 'Average', value: 'average' },
{ id: 'terrible', label: 'Terrible', value: 'terrible' }
];
</script>
<RadioGroup bind:value {options} direction="col" /> Properties
Name
Type
Description
value
Type
string
Default: ""
The selected value of the radio group
options
Type
{ id: string; label: string; value: string }[]
Default: []
Array of options to display in the radio group
direction
Type
"row" | "col"
Default: "col"
The direction of the radio group items
rootClass
Type
string
Default: ""
Additional classes for the root element