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:

tsx
import { Switch } from '@skeletonlabs/skeleton-react';

export default function Anatomy() {
	return (
		<Switch>
			<Switch.Control>
				<Switch.Thumb />
			</Switch.Control>
			<Switch.Label />
			<Switch.HiddenInput />
		</Switch>
	);
}

API Reference

Unable to load component information for react/switch

View page on GitHub