1"use client"
2
3import * as React from "react"
4import { cva, type VariantProps } from "class-variance-authority"
5import { cn } from "@/lib/utils"
6import { Toggle as TogglePrimitive } from "radix-ui"
7
8const toggleVariants = cva(
9 cn(
10 "group/toggle inline-flex items-center justify-center gap-2 rounded-pill border-2 border-ink whitespace-nowrap select-none",
11 "bg-paper font-sans font-bold text-ink",
12 "transition-[background-color,color] duration-[120ms] outline-none",
13 "not-data-[state=on]:hover:bg-cream",
14 "data-[state=on]:bg-ink data-[state=on]:text-paper",
15 "focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-violet",
16 "aria-invalid:border-danger",
17 "disabled:pointer-events-none disabled:border-dashed disabled:bg-cream disabled:text-muted",
18 "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
19 ),
20 {
21 variants: {
22 size: {
23 default: "h-11 px-5 text-[15px]",
24 sm: "h-11 px-4 text-[15px]",
25 lg: "h-14 px-7 text-lg",
26 },
27 },
28 defaultVariants: {
29 size: "default",
30 },
31 }
32)
33
34function Toggle({
35 className,
36 size = "default",
37 ...props
38}: React.ComponentProps<typeof TogglePrimitive.Root> &
39 VariantProps<typeof toggleVariants>) {
40 return (
41 <TogglePrimitive.Root
42 data-slot="toggle"
43 className={cn(toggleVariants({ size, className }))}
44 {...props}
45 />
46 )
47}
48
49export { Toggle, toggleVariants }
50