Switch

Base UI

An immediate on or off preference.

ReadyResponsive

Usage

Package export
tsx
"use client"

import { Label } from "@jnpll/elements-ui/label"
import { Switch } from "@jnpll/elements-ui/switch"

export function SwitchDemo() {
  return (
    <div className="flex items-center space-x-2">
      <Switch id="airplane-mode" />
      <Label htmlFor="airplane-mode">Airplane Mode</Label>
    </div>
  )
}

export default SwitchDemo;

Examples

Disabled state

API Reference

PropType / descriptionDefault
checked / defaultCheckedboolean

Controlled or initial checked state.

false
onCheckedChangefunction

Receives checked-state changes.

-
classNamestring

Additional classes, merged with the component styles.

-

Composition & accessibility

Import the composition slots shown in the example. Keep labels and descriptions meaningful; interactive primitives provide keyboard and focus behavior. See the source for the complete typed API.