Add iconClassName prop in Button

merge-requests/3333/head
danidfra 2025-03-15 15:05:26 -03:00
rodzic bad386ee23
commit 2d8859ead4
1 zmienionych plików z 4 dodań i 1 usunięć

Wyświetl plik

@ -14,6 +14,8 @@ interface IButton {
children?: React.ReactNode; children?: React.ReactNode;
/** Extra class names for the button. */ /** Extra class names for the button. */
className?: string; className?: string;
/** Extra class names for the icon. */
iconClassName?: string;
/** Prevent the button from being clicked. */ /** Prevent the button from being clicked. */
disabled?: boolean; disabled?: boolean;
/** Specifies the icon element as 'svg' or 'img'. */ /** Specifies the icon element as 'svg' or 'img'. */
@ -49,6 +51,7 @@ const Button = forwardRef<HTMLButtonElement, IButton>((props, ref): JSX.Element
to, to,
type = 'button', type = 'button',
className, className,
iconClassName,
} = props; } = props;
const body = text || children; const body = text || children;
@ -65,7 +68,7 @@ const Button = forwardRef<HTMLButtonElement, IButton>((props, ref): JSX.Element
return null; return null;
} }
return <Icon src={icon} className='size-4' element={iconElement} />; return <Icon src={icon} className={clsx('size-4', iconClassName)} element={iconElement} />;
}; };
const handleClick: React.MouseEventHandler<HTMLButtonElement> = useCallback((event) => { const handleClick: React.MouseEventHandler<HTMLButtonElement> = useCallback((event) => {