1. framework components
  2. switch

Switch

Toggle between two states, such as on/off.

Checked: false

Color

Use the Tailwind data attribute syntax to target the state using data-[state=checked]

List

Use the Label component to create a list layout.



Icons

Add icons to act as state indicators.

Direction

Set the text direction (ltr or rtl) using the dir prop.

Anatomy

Here’s an overview of how the Switch component is structured in code:

svelte
<script lang="ts">
	import { Switch } from '@skeletonlabs/skeleton-svelte';
</script>

<Switch>
	<Switch.Control>
		<Switch.Thumb />
	</Switch.Control>
	<Switch.Label />
	<Switch.HiddenInput />
</Switch>

API Reference

Unable to load component information for svelte/switch

View page on GitHub