52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import * as React from "react";
|
|
import { Slot } from "@radix-ui/react-slot";
|
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
|
|
import { cn } from "~/lib/utils";
|
|
|
|
const buttonVariants = cva(
|
|
"inline-flex shrink-0 items-center justify-center gap-2 rounded-[14px] text-sm font-semibold whitespace-nowrap transition-all outline-none focus-visible:ring-2 focus-visible:ring-primary/30 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default: "bg-primary text-white shadow-sm hover:bg-primary/90",
|
|
outline:
|
|
"border border-border-soft bg-surface text-foreground hover:bg-surface-soft",
|
|
secondary:
|
|
"bg-primary-light text-primary hover:bg-primary-light/80",
|
|
ghost: "text-muted-foreground hover:bg-surface-soft hover:text-foreground",
|
|
},
|
|
size: {
|
|
default: "h-11 px-5",
|
|
sm: "h-9 px-4 text-xs",
|
|
lg: "h-12 px-6 text-base",
|
|
icon: "size-11",
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: "default",
|
|
size: "default",
|
|
},
|
|
},
|
|
);
|
|
|
|
function Button({
|
|
className,
|
|
variant = "default",
|
|
size = "default",
|
|
asChild = false,
|
|
...props
|
|
}: React.ComponentProps<"button"> &
|
|
VariantProps<typeof buttonVariants> & { asChild?: boolean }) {
|
|
const Comp = asChild ? Slot : "button";
|
|
|
|
return (
|
|
<Comp
|
|
className={cn(buttonVariants({ variant, size, className }))}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export { Button, buttonVariants };
|