Skip to content
Drivn logoDrivn

Switch

Toggle switch with smooth transition.

Preview

Off

Installation

npx drivn add switch

Usage

1"use client"
2
3import { useState } from "react"
4import { Switch } from "@/components/ui/switch"
5
6export default function Page() {
7 const [enabled, setEnabled] = useState(false)
8
9 return (
10 <Switch
11 checked={enabled}
12 onChange={setEnabled}
13 />
14 )
15}

API Reference

PropTypeDefaultDescription
checkedbooleanfalseWhether the switch is toggled on
onChange(checked: boolean) => voidCallback fired when the switch is toggled
classNamestringAdditional CSS classes to apply