Forms

Switch

An on/off switch over a native checkbox, so focus, keyboard, forms and screen readers come from the browser.

view .md
Preview
Installation
terminal
bash
npx @entrepta/cli@latest add switch

// Resolves dependencies, copies the source, and installs npm packages automatically.

Usage
switch.tsx
tsx
import { Switch } from "@/components/entrepta/switch"

<Switch label="send me a copy" defaultChecked />
<Switch label="notifications" checked={on} onChange={(e) => setOn(e.target.checked)} />
Props
PropTypeDefaultDescription
labelReactNode-Clickable label next to the switch
checkedboolean-Controlled state
defaultCheckedboolean-Uncontrolled starting state
disabledbooleanfalseDims and disables
Active theme: entrepta, dark mode.