Open History to see the last commit
1import * as React from 'react'
2import * as SwitchPrimitive from '@radix-ui/react-switch'
3
4import { cn } from '../../lib/utils'
5
6function Switch({
7 className,
8 ...props
9}: React.ComponentProps<typeof SwitchPrimitive.Root>) {
10 return (
11 <SwitchPrimitive.Root
12 data-slot="switch"
13 className={cn(
14 'peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 border-1 border-gray-500/30',
15 className,
16 )}
17 {...props}
18 >
19 <SwitchPrimitive.Thumb
20 data-slot="switch-thumb"
21 className={cn(
22 'bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0',
23 )}
24 />
25 </SwitchPrimitive.Root>
26 )
27}
28
29export { Switch }