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