CoolFace
Apppublic

FLASHback1/bingo

sourceHugging Facemitupdated 3y agoView on Hugging Face
0likes
button.tsx58 linesDownload Raw Back to ui
1import * as React from 'react'2import { Slot } from '@radix-ui/react-slot'3import { cva, type VariantProps } from 'class-variance-authority'4 5import { cn } from '@/lib/utils'6 7const buttonVariants = cva(8  'inline-flex items-center justify-center rounded-md text-sm font-medium shadow ring-offset-background transition-colors outline-none disabled:pointer-events-none disabled:opacity-50',9  {10    variants: {11      variant: {12        default:13          'bg-primary text-primary-foreground shadow-md hover:bg-primary/90',14        destructive:15          'bg-destructive text-destructive-foreground hover:bg-destructive/90',16        outline:17          'border border-input hover:bg-accent hover:text-accent-foreground',18        secondary:19          'bg-secondary text-secondary-foreground hover:bg-secondary/80',20        ghost: 'shadow-none hover:bg-accent hover:text-accent-foreground',21        link: 'text-primary underline-offset-4 shadow-none hover:underline'22      },23      size: {24        default: 'h-8 px-4 py-2',25        sm: 'h-8 rounded-md px-3',26        lg: 'h-11 rounded-md px-8',27        icon: 'h-8 w-8 p-0'28      }29    },30    defaultVariants: {31      variant: 'default',32      size: 'default'33    }34  }35)36 37export interface ButtonProps38  extends React.ButtonHTMLAttributes<HTMLButtonElement>,39    VariantProps<typeof buttonVariants> {40  asChild?: boolean41}42 43const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(44  ({ className, variant, size, asChild = false, ...props }, ref) => {45    const Comp = asChild ? Slot : 'button'46    return (47      <Comp48        className={cn(buttonVariants({ variant, size, className }))}49        ref={ref}50        {...props}51      />52    )53  }54)55Button.displayName = 'Button'56 57export { Button, buttonVariants }58