import React from 'react' import { Button as AriakitButton, ButtonProps } from '@ariakit/react' import { Text, Props as TextProps } from '../Text/Text' import * as styles from './styles.css' import { Box } from '../Box/Box' import { IconProps } from '../icons' import clsx, { ClassValue } from 'clsx' export type Props = ButtonProps & styles.Variants & { /** An alias for iconLeft as a convenience for icon-only tags. */ icon?: React.ReactElement iconLeft?: React.ReactElement iconRight?: React.ReactElement className?: ClassValue | ClassValue[] lines?: TextProps['lines'] wordBreak?: TextProps['break'] onIconLeftClick?: () => void onIconRightClick?: () => void } const buttonToTextSize = { small: 'xSmall', medium: 'xSmall', large: 'small', } as const export const Tag: React.FC> = ({ children, className, icon, iconLeft, iconRight, emphasis = styles.defaultEmphasis, shape = styles.defaultShape, size = styles.defaultSize, kind = styles.defaultKind, lines, wordBreak, onIconLeftClick, onIconRightClick, ...buttonProps }) => { const textSize: TextProps['size'] = buttonToTextSize[size] icon = icon || iconLeft return ( {icon && ( {icon} )} {children && ( {children} )} {iconRight && ( {iconRight} )} ) }