main
tsx 53 lines 2.43 KB
Raw
1 import * as React from "react";
2 import { Slot } from "@radix-ui/react-slot";
3 import { cva, type VariantProps } from "class-variance-authority";
4
5 import { cn } from "@/lib/utils";
6
7 const buttonVariants = cva(
8 "inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-semibold ring-offset-background transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
9 {
10 variants: {
11 variant: {
12 default: "bg-primary text-primary-foreground hover:bg-lime-dark rounded-full",
13 destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90 rounded-full",
14 outline: "border-2 border-foreground bg-transparent text-foreground hover:bg-foreground hover:text-background rounded-full",
15 secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 rounded-full",
16 ghost: "hover:bg-accent hover:text-accent-foreground rounded-lg",
17 link: "text-primary underline-offset-4 hover:underline",
18 // Wise-style variants
19 hero: "bg-primary text-primary-foreground hover:bg-lime-dark rounded-full shadow-lg hover:shadow-xl hover:-translate-y-0.5",
20 "hero-outline": "border-2 border-primary bg-transparent text-primary hover:bg-primary hover:text-primary-foreground rounded-full",
21 navy: "bg-secondary text-secondary-foreground hover:bg-navy-light rounded-full",
22 "navy-outline": "border-2 border-secondary bg-transparent text-secondary hover:bg-secondary hover:text-secondary-foreground rounded-full",
23 },
24 size: {
25 default: "h-11 px-6 py-2",
26 sm: "h-9 px-4",
27 lg: "h-14 px-8 text-base",
28 xl: "h-16 px-10 text-lg",
29 icon: "h-10 w-10",
30 },
31 },
32 defaultVariants: {
33 variant: "default",
34 size: "default",
35 },
36 },
37 );
38
39 export interface ButtonProps
40 extends React.ButtonHTMLAttributes<HTMLButtonElement>,
41 VariantProps<typeof buttonVariants> {
42 asChild?: boolean;
43 }
44
45 const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
46 ({ className, variant, size, asChild = false, ...props }, ref) => {
47 const Comp = asChild ? Slot : "button";
48 return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />;
49 },
50 );
51 Button.displayName = "Button";
52
53 export { Button, buttonVariants };