Radio Group
Allow users to select a single choice from a list.
Preview
Code
Basic Example
<script>
import { RadioGroup, RadioGroupItem } from 'lithesome';
let value = $state();
</script>
<RadioGroup bind:value>
<RadioGroupItem value="item-1">Item 1</RadioGroupItem>
<RadioGroupItem value="item-2">Item 2</RadioGroupItem>
<RadioGroupItem value="item-3">Item 3</RadioGroupItem>
</RadioGroup>
API Reference
<RadioGroup />
| Property | Type | Description |
|---|---|---|
value | string | The currently selected value. |
disabled | boolean | Disables the entire group, stops all events from firing. |
onValueChanged | (value: string) => void | Fires whenever the `value` prop changes. |
ref | E | The reference to the underlying element. |
children | Snippet<[ S extends Record<string, any> ? S : never ]> | The default snippet to render. |
custom | Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]> | Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it. |
| State | Type | Description |
|---|---|---|
value | string | The current value of the group. |
disabled | boolean | True if the group is disabled. |
<RadioGroupItem />
| Property | Type | Description |
|---|---|---|
value | string | The unique value of the item. |
disabled | boolean | Disables the entire group, stops all events from firing. |
ref | E | The reference to the underlying element. |
children | Snippet<[ S extends Record<string, any> ? S : never ]> | The default snippet to render. |
custom | Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]> | Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it. |
| State | Type | Description |
|---|---|---|
selected | boolean | The current value of the group. |
disabled | boolean | True if the group is disabled. |