2023-11-08 12:02:00 +03:00

26 lines
812 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 px-5 py-2.5 text-sm font-medium text-white', {
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} />
)
);