Skip to content

Commit

Permalink
Button: component added with variants
Browse files Browse the repository at this point in the history
  • Loading branch information
nirnejak committed Jul 1, 2024
1 parent 46fe438 commit 2a92d8b
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions components/atoms/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as React from "react"

import { cva, type VariantProps } from "class-variance-authority"

import classNames from "@/utils/classNames"

const buttonVariants = cva("rounded-md", {
variants: {
variant: {
primary: "bg-blue-500",
secondary: "bg-gray-500",
},
size: {
sm: "px-2 py-1",
md: "px-3 py-2",
lg: "px-4 py-3",
},
defaultVariants: {
variant: "primary",
size: "md",
},
},
})

export interface Props
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean
}

const Button: React.FC<Props> = ({ children, className, ...props }) => {
return (
<button
{...props}
className={classNames(
buttonVariants({ variant: "primary", size: "md" }),
className
)}
>
{children}
</button>
)
}

export default Button

0 comments on commit 2a92d8b

Please sign in to comment.