The Coline design system: accessible React components for Coline Apps, themed live by the host workspace, and for Coline Sites in light and dark. Tailwind v4 stylesheet included. MIT.
| 5 |
| import { Toggle as TogglePrimitive } from "radix-ui" |
| 6 |
| 7 | import { cn } from "../lib/utils" |
| 8 |
| 9 | const toggleVariants = cva( |
| 10 | "group/toggle inline-flex items-center justify-center gap-1 rounded-[min(var(--radius-2xl),12px)] text-sm font-medium whitespace-nowrap transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", |
| 11 | { |
| 12 | variants: { |
| 13 | variant: { |
| 14 | default: "bg-transparent", |
| 15 | outline: "border border-input bg-transparent hover:bg-muted", |
| 16 | }, |
| 17 | size: { |
| 18 | default: "h-9 min-w-9 px-2.5", |
| 19 | sm: "h-8 min-w-8 px-2", |
| 20 | lg: "h-10 min-w-10 px-2.5", |
| 21 | }, |
| 22 | }, |
| 23 | defaultVariants: { |
| 24 | variant: "default", |
| 25 | size: "default", |
| 26 | }, |
| 27 | } |
| 28 | ) |
| 29 |
| 30 | function Toggle({ |
| 31 | className, |
| 32 | variant = "default", |
| 33 | size = "default", |
| 34 | ...props |
| 35 | }: React.ComponentProps<typeof TogglePrimitive.Root> & |
| 36 | VariantProps<typeof toggleVariants>) { |
| 37 | return ( |
| 38 | <TogglePrimitive.Root |
| 39 | data-slot="toggle" |
| 40 | className={cn(toggleVariants({ variant, size, className }))} |
| 41 | {...props} |
| 42 | /> |
| 43 | ) |
| 44 | } |
| 45 |
| 46 | export { Toggle, toggleVariants } |
| 47 |