Switch
nivalis-ui/switchFreeComponent
A switch component.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/nivalis-studio/nivalis-ui/main/public/r/switch.jsonSource
1'use client';23import { Root, Thumb } from '@radix-ui/react-switch';4import { cn } from '@/lib/classnames';5import type * as React from 'react';67function Switch({ className, ...props }: React.ComponentProps<typeof Root>) {8 return (9 <Root10 className={cn(11 'peer inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs outline-none transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80',12 className,13 )}14 data-slot='switch'15 {...props}16 >17 <Thumb18 className={cn(19 'pointer-events-none block size-4 rounded-full bg-background ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground',20 )}21 data-slot='switch-thumb'22 />23 </Root>24 );25}2627export { Switch };
What it pulls in
npm packages
Files it writes
More from @nivalis/ui
All 23 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | @nivalis/ui | Components | Free | 1 dep | |
| Avataravatar | @nivalis/ui | Components | Free | 1 dep | |
| Badgebadge | @nivalis/ui | Components | Free | no deps | |
| Breadcrumbbreadcrumb | @nivalis/ui | Components | Free | 1 dep | |
| Buttonbutton | @nivalis/ui | Components | Free | 1 dep | |
| Cardcard | @nivalis/ui | Components | Free | no deps | |
| Checkboxcheckbox | @nivalis/ui | Components | Free | 1 dep | |
| Commandcommand | @nivalis/ui | Components | Free | 2 deps · 2 files |
