import cx from 'classnames'; import { forwardRef } from 'react'; import Icon from '../icon'; const PRESET_COLOR = { red: true, green: true, yellow: true, blue: true, grey: true, }; export interface ITagProps extends React.HTMLAttributes { theme?: keyof typeof PRESET_COLOR; outline?: boolean; rounded?: boolean; closable?: boolean; onClose?: React.MouseEventHandler; style?: React.CSSProperties; closeButtonStyle?: React.CSSProperties; visible?: boolean; size?: 'small' | 'medium' | 'large'; } export const Tag = forwardRef( ( { size = 'small', theme = 'grey', outline, rounded = true, closable, children, className, onClose, closeButtonStyle, visible = true, ...rest }, ref ) => { if (!visible) { return null; } const colorPart = PRESET_COLOR[theme] ? `-${theme}` : ''; const outlinePart = outline ? '-outline' : ''; return (
{children}
{closable ? ( ) : null}
); } ); Tag.displayName = 'ZentTag'; export default Tag;