import React from 'react'

import { useStyleConfig, vui } from '../core'
import Icon, { IconProps } from '../icon'
import { cs } from '../utils'
import { useTagContext } from './context'

/** Displays an icon within the Tag. */
export const TagIcon = vui<'svg', IconProps>((props, ref) => {
  const { className, ...rest } = props
  const styles = useStyleConfig('Tag', useTagContext())

  return <Icon className={cs('vui-tagIcon', className)} ref={ref} {...styles.icon} {...rest} />
})

TagIcon.displayName = 'TagIcon'
export default TagIcon
