feat: add reusable Button component
This commit is contained in:
29
src/components/ui/Button.tsx
Normal file
29
src/components/ui/Button.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { cx } from '@styled-system/css'
|
||||
import { type ButtonVariantProps, button } from '@styled-system/recipes/button'
|
||||
import type { ButtonHTMLAttributes, DetailedHTMLProps, FC } from 'react'
|
||||
import type { MergeOmitting } from '@/types/helpers'
|
||||
|
||||
export type ButtonProps = MergeOmitting<
|
||||
DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>,
|
||||
ButtonVariantProps
|
||||
>
|
||||
|
||||
const Button: FC<ButtonProps> = ({
|
||||
className,
|
||||
type = 'button',
|
||||
children,
|
||||
...props
|
||||
}) => {
|
||||
const [buttonArgs, restProps] = button.splitVariantProps(props)
|
||||
return (
|
||||
<button
|
||||
type={type}
|
||||
{...restProps}
|
||||
className={cx(button(buttonArgs), className)}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
export default Button
|
||||
Reference in New Issue
Block a user