Checkbox

A control that lets users switch between a checked and unchecked state.

Preview
Code

Basic Example

<script>
	import { Checkbox } from 'lithesome';

	let checked = $state(false);
</script>

<Checkbox bind:checked>
	{#if checked}
		Check Icon
	{:else}
		Nothing
	{/if}
</Checkbox>

API Reference

<CheckboxGroup />

PropertyTypeDescription
checked CheckboxChecked

The current checked state.

disabled boolean

Disables the entire group, stops all events from firing.

onCheckedChange (checked: CheckboxChecked) => void

Fires whenever the `checked` prop is changed.

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
checkedCheckboxCheckedTrue if the button is checked.
disabledbooleanTrue if the group is disabled.

<CheckboxButton />

PropertyTypeDescription
checked CheckboxChecked

The current checked state.

disabled boolean

Disables the entire group, stops all events from firing.

name string

Renders an invisible `input[type="checkbox"]` element to be used for native form submissions. If no `value` prop is found, the default value is 'on'

required boolean

Makes the invisible checkbox required.

value string

The value of the invisible checkbox.

onCheckedChange (v: CheckboxChecked) => void

Fires whenever the `checked` prop is changed.

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
checkedCheckboxCheckedTrue if the button is checked.
disabledbooleanTrue if the group is disabled.

<CheckboxLabel />

PropertyTypeDescription
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
checkedCheckboxCheckedTrue if the button is checked.
disabledbooleanTrue if the group is disabled.