Files
edubox/server/components/ui/button.tsx
T
2026-06-06 19:55:41 +00:00

37 lines
1.5 KiB
TypeScript

import * as React from "react";
import { cn } from "@/lib/utils";
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: "default" | "outline" | "ghost" | "destructive";
size?: "default" | "sm" | "lg";
asChild?: boolean;
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant = "default", size = "default", asChild = false, children, ...props }, ref) => {
const Comp = asChild ? "span" : "button";
return (
<Comp
className={cn(
"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-ring disabled:pointer-events-none disabled:opacity-50",
variant === "default" && "bg-primary text-primary-foreground hover:bg-primary/90",
variant === "outline" && "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
variant === "ghost" && "hover:bg-accent hover:text-accent-foreground",
variant === "destructive" && "bg-destructive text-destructive-foreground hover:bg-destructive/90",
size === "default" && "h-10 px-4 py-2",
size === "sm" && "h-9 rounded-md px-3",
size === "lg" && "h-11 rounded-md px-8",
className
)}
ref={ref as any}
{...props as any}
>
{children}
</Comp>
);
}
);
Button.displayName = "Button";
export { Button };