Toggle
A two-state button that can be either on or off.
Installation
›pnpm dlx shadcn@latest add @evolphin/toggle
Usage
import { Toggle } from "@/components/ui/toggle";<Toggle>Toggle</Toggle>Type Definitions
interface ToggleProps {
/** The controlled pressed state of the toggle */
pressed?: boolean; /** The default pressed state when uncontrolled */
?: boolean;
/** Event handler called when the pressed state changes */
?: (: boolean) => void;
/** The visual style of the toggle */
?: "default" | "outline";
/** The size of the toggle */
?: "default" | "sm" | "lg";
}Examples
Default
Outline
With Text
Small
Large
API Reference
Toggle
| Prop | Type | Default | Description |
|---|---|---|---|
variant | `"default" \ | "outline"` | "default" |
size | `"default" \ | "sm" \ | "lg"` |
pressed | boolean | - | The controlled pressed state of the toggle. |
defaultPressed | boolean | - | The default pressed state when uncontrolled. |
onPressedChange | (pressed: boolean) => void | - | Event handler called when the pressed state changes. |
disabled | boolean | false | Whether the toggle is disabled. |
className | string | - | Additional CSS classes |