35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { cva, type VariantProps } from "class-variance-authority"
|
|
import type { ButtonHTMLAttributes } from "react"
|
|
|
|
import { cn } from "../lib/utils"
|
|
|
|
const buttonVariants = cva(
|
|
"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ring-offset-white",
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default: "bg-neutral-900 text-white hover:bg-neutral-800",
|
|
secondary: "bg-neutral-100 text-neutral-900 hover:bg-neutral-200",
|
|
ghost: "hover:bg-neutral-100 hover:text-neutral-900",
|
|
},
|
|
size: {
|
|
default: "h-10 px-4 py-2",
|
|
sm: "h-9 rounded-md px-3",
|
|
lg: "h-11 rounded-md px-8",
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: "default",
|
|
size: "default",
|
|
},
|
|
},
|
|
)
|
|
|
|
export interface ButtonProps
|
|
extends ButtonHTMLAttributes<HTMLButtonElement>,
|
|
VariantProps<typeof buttonVariants> {}
|
|
|
|
export function Button({ className, size, variant, ...props }: ButtonProps) {
|
|
return <button className={cn(buttonVariants({ variant, size }), className)} {...props} />
|
|
}
|