cjo93 commited on
Commit
1e09ac2
·
verified ·
1 Parent(s): 6a6476e

Create src/components/ui/button.tsx

Browse files
Files changed (1) hide show
  1. src/components/ui/button.tsx +52 -0
src/components/ui/button.tsx ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as React from "react"
2
+ import { Slot } from "@radix-ui/react-slot"
3
+ import { cva, type VariantProps } from "class-variance-authority"
4
+ import { cn } from "@/lib/utils"
5
+
6
+ const buttonVariants = cva(
7
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-white text-black hover:bg-white/90",
12
+ destructive: "bg-red-900 text-white hover:bg-red-900/90",
13
+ outline: "border border-white/10 bg-transparent hover:bg-white/5 text-white",
14
+ secondary: "bg-white/10 text-white hover:bg-white/20",
15
+ ghost: "hover:bg-white/5 hover:text-white",
16
+ link: "text-amber-500 underline-offset-4 hover:underline",
17
+ },
18
+ size: {
19
+ default: "h-10 px-4 py-2",
20
+ sm: "h-9 rounded-md px-3",
21
+ lg: "h-11 rounded-md px-8",
22
+ icon: "h-10 w-10",
23
+ },
24
+ },
25
+ defaultVariants: {
26
+ variant: "default",
27
+ size: "default",
28
+ },
29
+ }
30
+ )
31
+
32
+ export interface ButtonProps
33
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
34
+ VariantProps<typeof buttonVariants> {
35
+ asChild?: boolean
36
+ }
37
+
38
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
39
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
40
+ const Comp = asChild ? Slot : "button"
41
+ return (
42
+ <Comp
43
+ className={cn(buttonVariants({ variant, size, className }))}
44
+ ref={ref}
45
+ {...props}
46
+ />
47
+ )
48
+ }
49
+ )
50
+ Button.displayName = "Button"
51
+
52
+ export { Button, buttonVariants }