Search

Search documentation

Switch

A control that allows the user to toggle between checked and not checked.

Installation

pnpm dlx shadcn@latest add @evolphin/switch

Usage

import { Switch } from "@/components/ui/switch";
<Switch />

Type Definitions

interface SwitchProps {
  /** The controlled checked state of the switch */
  checked?: boolean;
SwitchProps.checked?: boolean | undefined

The controlled checked state of the switch

/** The default checked state when uncontrolled */ ?: boolean; /** Event handler called when the checked state changes */ ?: (: boolean) => void; /** Whether the switch is disabled */ ?: boolean; }

Examples

Default

API Reference

Switch

PropTypeDefaultDescription
checkedboolean-The controlled checked state of the switch.
defaultCheckedboolean-The default checked state when uncontrolled.
onCheckedChange(checked: boolean) => void-Event handler called when the checked state changes.
disabledbooleanfalseWhether the switch is disabled.
requiredbooleanfalseWhether the switch is required.
namestring-The name of the switch.
valuestring"on"The value of the switch.
classNamestring-Additional CSS classes

On this page