Component

Switch

A compact native switch for binary settings and panel preferences.

Preview

Installation

Install the package, then import the component and shared stylesheet in your app.

Package install

Install the package when you want components imported from axie-ui.

install
pnpm add axie-ui

Import

code
import "axie-ui/styles.css";import { Switch } from "axie-ui";

Registry install

Use the direct URL when you want shadcn to copy editable source into your app. This works without the official registry and does not install axie-ui.

registry
pnpm dlx shadcn@latest add https://axie.alexi.life/r/switch.json

Copied source import

code
import "@/styles/axie.css";import { Switch } from "@/components/axie/switch";

Prefer @axie/switch? Add the Axie namespace once from the Installation page, then use that shorthand.

Usage

code
import { Switch } from "axie-ui";export function Example() {  return <Switch label="Budget reset alerts" defaultChecked />;}

Accessibility

  • Use switches for immediate on/off settings, not multi-step choices.
  • Keep the label visible and specific.
  • Use `role="switch"` and reflect checked state with the native input.

API Reference

PropTypeDefaultDescription
labelReactNode-Optional label rendered before the switch.
descriptionReactNode-Optional supporting copy.
...propsInputHTMLAttributes<HTMLInputElement>-Accepts native checkbox props except type.