bloxa

Switch

FREE

Toggle switch in two sizes with optional icons inside the thumb.

Playground

Change the props and watch the component and its code update live.

Props
Code
import { Moon, Sun } from "lucide-react";
import { Label } from "@/components/ui/field";
import { Switch } from "@/components/ui/switch";

<Switch
  id="switch"
  checkedIcon={<Moon />}
  uncheckedIcon={<Sun />}
/>
<Label htmlFor="switch">Dark mode</Label>

Installation

Terminal
npx @bloxa/cli add switch
# or: npx shadcn@latest add @bloxa/switch

Packages installed automatically: radix-ui

Examples

Sizes

With icons

API reference

Every component also accepts the props of the element it renders.

Switch

PropTypeDefaultDescription
size"sm" | "md""md"Size.
checkedIconReactNode—Thumb icon while on.
uncheckedIconReactNode—Thumb icon while off.