Files
yaak/src-web/components/IconButton.tsx
Gregory Schier db2d786d50 Start of themes
2023-03-07 11:24:38 -08:00

31 lines
822 B
TypeScript

import { forwardRef } from 'react';
import type { IconProps } from './Icon';
import { Icon } from './Icon';
import type { ButtonProps } from './Button';
import { Button } from './Button';
import classnames from 'classnames';
type Props = Omit<IconProps, 'size'> &
ButtonProps<typeof Button> & {
iconClassName?: string;
};
export const IconButton = forwardRef<HTMLButtonElement, Props>(function IconButton(
{ icon, spin, className, iconClassName, ...props }: Props,
ref,
) {
return (
<Button ref={ref} className={classnames(className, 'group')} {...props}>
<Icon
icon={icon}
spin={spin}
className={classnames(
iconClassName,
'text-gray-700 group-hover:text-gray-900',
props.disabled && 'opacity-70',
)}
/>
</Button>
);
});