BetaPublic beta — Read the release notes
Documentation

Switch

Binary toggle with on/off semantics.

Package
@solidiom/switch
Version
0.0.1-next.0
Status
stable

Preview

This preview uses documentation-only styling. Ship with one of the included recipe outputs (CSS, Tailwind, or UnoCSS) for production styles.

Binary toggle with on/off semantics.

Usage

Compose Root, Thumb.

import * as Switch from "@solidiom/switch"

;<Switch.Root>Switch content</Switch.Root>

Installation

Install the package with pnpm add @solidiom/switch. The package requires compatible solid-js and @solidjs/web peer dependencies.

Parts

Switch exposes 2 parts:

  • Rootdata-part="root".
  • Thumbdata-part="thumb".

Styling

Switch carries data-scope="switch" and data-part attributes on each part for CSS/recipe targeting. State attributes like data-state, data-disabled, and data-highlighted are exposed where applicable.

Keyboard & behavior

KeyBehavior
SpaceToggles the switch between on and off.
EnterToggles the switch between on and off.

SSR and hydration

Switch renders as semantic HTML during server rendering. Interactive behavior (keyboard handlers, state management) activates on hydration without layout shift.