2023-11-09 23:38:49 +03:00

29 lines
870 B
TypeScript

import { cn } from './utils';
import type { VariantProps } from 'class-variance-authority';
import { cva } from 'class-variance-authority';
import type { ButtonHTMLAttributes } from 'react';
import { forwardRef } from 'react';
const variants = cva(
'rounded-sm h-10 px-5 py-2.5 text-sm font-medium text-white transition-all ease-in-out',
{
defaultVariants: {
color: 'default',
},
variants: {
color: {
danger: 'bg-danger hover:bg-danger-700',
default: 'bg-primary hover:bg-primary-700',
},
},
}
);
export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof variants>;
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
({ className, color, ...props }, ref) => (
<button type="button" className={cn(variants({ className, color }))} ref={ref} {...props} />
)
);