Search

Search documentation

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;
ToggleProps.pressed?: boolean | undefined

The controlled pressed state of the toggle

/** 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

PropTypeDefaultDescription
variant`"default" \"outline"`"default"
size`"default" \"sm" \"lg"`
pressedboolean-The controlled pressed state of the toggle.
defaultPressedboolean-The default pressed state when uncontrolled.
onPressedChange(pressed: boolean) => void-Event handler called when the pressed state changes.
disabledbooleanfalseWhether the toggle is disabled.
classNamestring-Additional CSS classes

On this page