all repos — snow-editor @ 65993a713586363acceab129af67161a5fbe71cc

small and cozy markdown, and orgmode editor

src/components/IconButton.jsx (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
export default function IconButton({
  icon,
  label,
  variant = 'default',
  title,
  className = '',
  type = 'button',
  ...rest
}) {
  const variantClass = variant === 'ghost' ? ' btn-ghost' : '';
  const tooltip = title ?? label;

  return (
    <button
      type={type}
      className={`btn btn-icon${variantClass}${className ? ` ${className}` : ''}`}
      aria-label={label}
      title={tooltip}
      {...rest}
    >
      {icon}
    </button>
  );
}