Skip to content
Snippets Groups Projects
Button.tsx 849 B
Newer Older
  • Learn to ignore specific revisions
  • import { ReactNode } from "react"
    
    interface ButtonProps {
      type?: "button" | "reset" | "submit"
    
    Jacopo Gasparetto's avatar
    Jacopo Gasparetto committed
      className?: string,
    
      title: string,
      icon?: ReactNode
    
      onClick?: () => void
    
    }
    
    export const Button = (props: ButtonProps) => {
    
      const {
        type,
        className,
        title,
        icon,
        disabled,
        onClick
      } = props;
    
      let buttonClasses = className + " border border-color rounded p-4 "
      buttonClasses +=
        (disabled === true) ? "text-neutral-200" : "hover:bg-neutral-200";
    
    
      return (
    
        <button
          className={buttonClasses}
          type={type}
          onClick={onClick}
          disabled={disabled}
        >
          <div className="flex w-full">
            {icon ?
              <div className="w-5">{icon}</div>
              : null}
            <div className="ml-4">
              {title}
    
            </div>
    
        </button>