Skip to content

Commit a61e25c

Browse files
festus-sulumetiorama254
authored andcommitted
feat(ui): add Button component via shadcn/ui
1 parent 331d6bc commit a61e25c

4 files changed

Lines changed: 120 additions & 101 deletions

File tree

package-lock.json

Lines changed: 43 additions & 93 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@
1818
"validate"
1919
],
2020
"dependencies": {
21-
"@headlessui/react": "^2.2.9",
22-
"@types/react-google-recaptcha": "^2.1.9",
23-
"axios": "^1.13.2",
24-
"next": "16.0.5",
25-
"react": "19.2.0",
26-
"react-dom": "19.2.0",
27-
"react-google-recaptcha": "^3.1.0",
28-
"react-icons": "^5.5.0"
21+
"@headlessui/react": "^1.7.3",
22+
"@radix-ui/react-slot": "^1.2.4",
23+
"@types/react-google-recaptcha": "^2.1.5",
24+
"axios": "^1.7.7",
25+
"class-variance-authority": "^0.7.1",
26+
"clsx": "^2.1.1",
27+
"lucide-react": "^0.564.0",
28+
"next": "12.3.1",
29+
"react": "18.1.0",
30+
"react-dom": "18.1.0",
31+
"react-google-recaptcha": "^2.1.0",
32+
"react-icons": "^5.3.0",
33+
"tailwind-merge": "^3.4.0",
34+
"tailwindcss-animate": "^1.0.7"
2935
},
3036
"devDependencies": {
3137
"@formspree/react": "^3.0.0",

src/components/ui/button.tsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
9+
{
10+
variants: {
11+
variant: {
12+
default:
13+
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
14+
destructive:
15+
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
16+
outline:
17+
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
18+
secondary:
19+
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
20+
ghost: "hover:bg-accent hover:text-accent-foreground",
21+
link: "text-primary underline-offset-4 hover:underline",
22+
},
23+
size: {
24+
default: "h-9 px-4 py-2",
25+
sm: "h-8 rounded-md px-3 text-xs",
26+
lg: "h-10 rounded-md px-8",
27+
icon: "h-9 w-9",
28+
},
29+
},
30+
defaultVariants: {
31+
variant: "default",
32+
size: "default",
33+
},
34+
}
35+
)
36+
37+
export interface ButtonProps
38+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
39+
VariantProps<typeof buttonVariants> {
40+
asChild?: boolean
41+
}
42+
43+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
44+
({ className, variant, size, asChild = false, ...props }, ref) => {
45+
const Comp = asChild ? Slot : "button"
46+
return (
47+
<Comp
48+
className={cn(buttonVariants({ variant, size, className }))}
49+
ref={ref}
50+
{...props}
51+
/>
52+
)
53+
}
54+
)
55+
Button.displayName = "Button"
56+
57+
export { Button, buttonVariants }

src/lib/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { clsx, type ClassValue } from "clsx"
2+
import { twMerge } from "tailwind-merge"
3+
4+
export function cn(...inputs: ClassValue[]) {
5+
return twMerge(clsx(inputs))
6+
}

0 commit comments

Comments
 (0)