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 />

PropertyTypeDescription
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.

StateTypeDescription
valuestringThe current value of the group.
disabledbooleanTrue if the group is disabled.

<RadioGroupItem />

PropertyTypeDescription
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.

StateTypeDescription
selectedbooleanThe current value of the group.
disabledbooleanTrue if the group is disabled.