switch
neobrutalui/switchFreeComponent
Toggle a boolean setting on or off.
Live preview
live · rendered by the registry
Rendered by neobrutalui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.neobrutalui.live/r/switch.jsonSource
1"use client"23import * as React from "react"4import { Switch as BaseSwitch } from "@base-ui/react/switch"5import { cn } from "@/lib/utils"67type SwitchRootProps = React.ComponentPropsWithoutRef<typeof BaseSwitch.Root>89type SwitchA11yProps =10 | { "aria-label": string; "aria-labelledby"?: string; id?: string }11 | { "aria-labelledby": string; "aria-label"?: string; id?: string }12 | { id: string; "aria-label"?: string; "aria-labelledby"?: string }1314type SwitchProps = Omit<SwitchRootProps, "aria-label" | "aria-labelledby" | "id"> & SwitchA11yProps1516const Switch = React.forwardRef<17 React.ComponentRef<typeof BaseSwitch.Root>,18 SwitchProps19>(({ className, ...props }, ref) => (20 <BaseSwitch.Root21 className={cn(22 "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-black transition-colors focus-brutal disabled:cursor-not-allowed disabled:opacity-50 data-checked:bg-main data-unchecked:bg-white",23 className24 )}25 {...props}26 ref={ref}27 >28 <BaseSwitch.Thumb className="pointer-events-none block h-4 w-4 rounded-full border-2 border-black bg-white ring-0 transition-transform data-checked:translate-x-5 data-checked:bg-black data-unchecked:translate-x-0.5" />29 </BaseSwitch.Root>30))31Switch.displayName = "Switch"3233export { Switch }
What it pulls in
npm packages
Other registry items
More from neobrutalui
All 24 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | neobrutalui | Components | Free | 2 deps | |
| alertalert | neobrutalui | Components | Free | 1 dep | |
| avataravatar | neobrutalui | Components | Free | no deps | |
| badgebadge | neobrutalui | Components | Free | 1 dep | |
| buttonbutton | neobrutalui | Components | Free | 1 dep | |
| cardcard | neobrutalui | Components | Free | no deps | |
| checkboxcheckbox | neobrutalui | Components | Free | 2 deps | |
| date-pickerdate-picker | neobrutalui | Components | Free | 2 deps |
