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.
| 4 |
| 5 | import { cn } from "../lib/utils"; |
| 6 |
| 7 | const buttonVariants = cva( |
| 8 | "group/button inline-flex shrink-0 items-center justify-center rounded-4xl border border-white/20 text-sm font-medium whitespace-nowrap transition-[color,background-color,border-color] duration-200 ease-out outline-none select-none focus-visible:border-ring disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20 dark:border-white/[0.06] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", |
| 9 | { |
| 10 | variants: { |
| 11 | variant: { |
| 12 | default: |
| 13 | "bg-gradient-to-b from-blue-50 to-blue-100 text-blue-700 border-blue-200/50 hover:from-blue-100 hover:to-blue-150 shadow-[inset_0_1px_0_0_rgba(255,255,255,0.1),0_1px_3px_0_rgba(0,0,0,0.1)] dark:from-blue-950/50 dark:to-blue-900/50 dark:text-blue-300 dark:border-blue-800/30 dark:hover:from-blue-900/60 dark:hover:to-blue-800/60 dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.05),0_1px_3px_0_rgba(0,0,0,0.3)]", |
| 14 | outline: |
| 15 | "border-border/40 bg-background/60 shadow-[inset_0_1px_0_rgba(255,255,255,0.5),inset_0_-1px_2px_rgba(0,0,0,0.03)] hover:bg-background/80 hover:shadow-[inset_0_1px_0_rgba(255,255,255,0.6),inset_0_-1px_3px_rgba(0,0,0,0.04)] hover:text-foreground active:shadow-[inset_0_2px_6px_rgba(0,0,0,0.06)] dark:bg-white/[0.04] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04),inset_0_-1px_2px_rgba(0,0,0,0.2)] dark:hover:bg-white/[0.07] dark:hover:shadow-[inset_0_1px_0_rgba(255,255,255,0.06),inset_0_-1px_3px_rgba(0,0,0,0.25)] dark:active:shadow-[inset_0_2px_6px_rgba(0,0,0,0.35)] aria-expanded:bg-muted aria-expanded:text-foreground aria-expanded:shadow-[inset_0_2px_4px_rgba(0,0,0,0.06)]", |
| 16 | secondary: |
| 17 | "bg-secondary/70 text-secondary-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.6),inset_0_-1px_2px_rgba(0,0,0,0.04)] hover:bg-secondary/85 hover:shadow-[inset_0_1px_0_rgba(255,255,255,0.7),inset_0_-1px_3px_rgba(0,0,0,0.05)] active:shadow-[inset_0_2px_6px_rgba(0,0,0,0.07)] dark:bg-secondary/50 dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04),inset_0_-1px_2px_rgba(0,0,0,0.2)] dark:hover:bg-secondary/60 dark:hover:shadow-[inset_0_1px_0_rgba(255,255,255,0.06),inset_0_-1px_3px_rgba(0,0,0,0.25)] dark:active:shadow-[inset_0_2px_6px_rgba(0,0,0,0.35)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground aria-expanded:shadow-[inset_0_2px_4px_rgba(0,0,0,0.05)]", |
| 18 | ghost: |
| 19 | "hover:bg-muted/50 hover:text-foreground hover:shadow-[inset_0_1px_0_rgba(255,255,255,0.4),inset_0_-1px_2px_rgba(0,0,0,0.03)] active:shadow-[inset_0_2px_5px_rgba(0,0,0,0.06)] dark:hover:bg-white/[0.04] dark:hover:shadow-[inset_0_1px_0_rgba(255,255,255,0.03),inset_0_-1px_2px_rgba(0,0,0,0.15)] dark:active:shadow-[inset_0_2px_5px_rgba(0,0,0,0.3)] aria-expanded:bg-muted aria-expanded:text-foreground", |
| 20 | destructive: |
| 21 | "bg-destructive/8 text-destructive shadow-[inset_0_1px_0_rgba(255,255,255,0.4),inset_0_-1px_2px_rgba(220,38,38,0.06)] hover:bg-destructive/12 hover:shadow-[inset_0_1px_0_rgba(255,255,255,0.5),inset_0_-1px_3px_rgba(220,38,38,0.08)] active:shadow-[inset_0_2px_6px_rgba(220,38,38,0.12)] focus-visible:border-destructive/40 dark:bg-destructive/15 dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.03),inset_0_-1px_2px_rgba(0,0,0,0.2)] dark:hover:bg-destructive/22 dark:hover:shadow-[inset_0_1px_0_rgba(255,255,255,0.05),inset_0_-1px_3px_rgba(0,0,0,0.25)] dark:active:shadow-[inset_0_2px_6px_rgba(0,0,0,0.35)]", |
| 22 | link: "text-primary underline-offset-4 hover:underline", |
| 23 | }, |
| 24 | size: { |
| 25 | default: |
| 26 | "h-9 gap-1.5 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5", |
| 27 | xs: "h-6 gap-1 px-2.5 text-xs has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3", |
| 28 | sm: "h-8 gap-1 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2", |
| 29 | lg: "h-10 gap-1.5 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3", |
| 30 | icon: "size-9", |
| 31 | "icon-xs": "size-6 [&_svg:not([class*='size-'])]:size-3", |
| 32 | "icon-sm": "size-8", |
| 33 | "icon-lg": "size-10", |
| 34 | }, |
| 35 | }, |
| 36 | defaultVariants: { |
| 37 | variant: "default", |
| 38 | size: "default", |
| 39 | }, |
| 40 | } |
| 41 | ); |
| 42 |
| 43 | const Button = React.forwardRef< |
| 44 | HTMLButtonElement, |
| 45 | React.ComponentProps<"button"> & |
| 46 | VariantProps<typeof buttonVariants> & { |
| 47 | asChild?: boolean; |
| 48 | } |
| 49 | >(function Button( |
| 50 | { |
| 51 | className, |
| 52 | variant = "default", |
| 53 | size = "default", |
| 54 | asChild = false, |
| 55 | ...props |
| 56 | }, |
| 57 | ref, |
| 58 | ) { |
| 59 | const Comp = asChild ? Slot.Root : "button"; |
| 60 |
| 61 | return ( |
| 62 | <Comp |
| 63 | ref={ref} |
| 64 | data-slot="button" |
| 65 | data-variant={variant} |
| 66 | data-size={size} |
| 67 | className={cn(buttonVariants({ variant, size, className }))} |
| 68 | {...props} |
| 69 | /> |
| 70 | ); |
| 71 | }); |
| 72 |
| 73 | export { Button, buttonVariants }; |
| 74 |