| 1 | import { Button as ButtonPrimitive } from "@base-ui/react/button"; |
| 2 | import { cn } |
| 3 | import { cva, type |
| 4 | |
| 5 | const buttonVariants = cva |
| 6 | "group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 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", |
| 7 | { |
| 8 | variants: { |
| 9 | variant: { |
| 10 | default: "bg-primary text-primary-foreground hover:bg-primary/90", |
| 11 | outline: |
| 12 | "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50", |
| 13 | secondary: |
| 14 | "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground", |
| 15 | ghost: |
| 16 | "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50", |
| 17 | destructive: |
| 18 | "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40", |
| 19 | link: "text-primary underline-offset-4 hover:underline", |
| 20 | }, |
| 21 | size: { |
| 22 | default: |
| 23 | "h-8 gap-1.5 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2", |
| 24 | xs: "h-6 gap-1 rounded-sm px-2 text-xs has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3", |
| 25 | sm: "h-7 gap-1 rounded-sm px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5", |
| 26 | lg: "h-9 gap-1.5 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3", |
| 27 | icon: "size-8", |
| 28 | "icon-xs": "size-6 rounded-sm [&_svg:not([class*='size-'])]:size-3", |
| 29 | "icon-sm": "size-7 rounded-sm", |
| 30 | "icon-lg": "size-9", |
| 31 | }, |
| 32 | }, |
| 33 | defaultVariants: { |
| 34 | variant: "default", |
| 35 | size: "default", |
| 36 | }, |
| 37 | }, |
| 38 | ); |
| 39 | |
| 40 | function Button({ |
| 41 | className, |
| 42 | variant = "default" |
| 43 | size = "default" |
| 44 | ...props |
| 45 | }: ButtonPrimitive. |
| 46 | return ( |
| 47 | <ButtonPrimitive |
| 48 | data-slot="button" |
| 49 | className={cn(buttonVariants |
| 50 | {...props} |
| 51 | /> |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | export { Button, buttonVariants |