Switch

A toggle switch for binary on/off states.

Anatomy

<script>
  import { Switch } from "@saas-ui/svelte/components/switch";
</script>

<Switch>Enable notifications</Switch>

Examples

Basic Accessibility

Basic switch with default styling.

Colours Accessibility

Use the colour prop to change the colour theme.

Disabled Accessibility

Use the disabled prop to disable the switch.

Sizes Accessibility

Use the size prop to change the size of the switch.

Thumb Label Accessibility

Use the thumbLabel prop to display icons or text on the switch thumb (the moving toggle).

Track Label Accessibility

Use the trackLabel prop to display icons or text on the switch track (the background container).

Variants Accessibility

Use the variant prop to change the visual style.

Props

Prop Type Default Description
size xs | sm | md | lg md The size of the switch.
variant solid | raised solid The visual variant of the switch.
colour gray | red | orange | yellow | green | teal | blue | cyan | purple | pink | rose accent The colour palette to use.
checked boolean - Whether the switch is checked.
disabled boolean - Whether the switch is disabled.
class text - CSS class to apply to the component.