buttonVariants.tsx raw
1 import { cva } from "class-variance-authority";
2
3 /** Shared with `Button`, `LinkButton`, and responsive button wrappers. */
4 export const buttonVariants = cva(
5 "inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
6 {
7 variants: {
8 variant: {
9 default:
10 "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
11 destructive:
12 "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
13 outline:
14 "border bg-background text-foreground shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
15 secondary:
16 "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
17 ghost:
18 "text-foreground hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
19 link: "text-foreground underline-offset-4 hover:underline",
20 positive: "bg-positive text-positive-foreground hover:bg-positive/80",
21 },
22 size: {
23 default: "h-9 px-4 py-2 has-[>svg]:px-3",
24 xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
25 sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
26 lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
27 icon: "size-9",
28 "icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
29 "icon-sm": "size-8",
30 "icon-lg": "size-10",
31 },
32 },
33 defaultVariants: {
34 variant: "default",
35 size: "default",
36 },
37 }
38 );
39