Switch
A switch component that toggles between on and off states with smooth transitions and proper accessibility attributes.
Import
import Switch from "$lib/components/Switch.svelte"; Basic Usage
Examples of switches in different states.
Properties
Name
Type
Description
toggleOn
Type
boolean
Default: false
The controlled state of the switch.
label
Type
string
Default: ""
Text label displayed next to the switch.
controlName
Type
string
Default: ""
The id and name attribute for the switch.
disabled
Type
boolean
Default: false
Whether the switch is disabled.
onClick
Type
() => void
Default: () => {}
Function called when the switch is clicked.
flexDirection
Type
string
Default: "flex flex-col"
Controls the flex direction of the switch container.