material-icon.tsx 743 B

12345678910111213141516171819202122232425262728293031323334
  1. import classNames from 'classnames'
  2. import React from 'react'
  3. import { bsVersion } from '@/features/utils/bootstrap-5'
  4. type IconProps = React.ComponentProps<'i'> & {
  5. type: string
  6. accessibilityLabel?: string
  7. modifier?: string
  8. }
  9. function MaterialIcon({
  10. type,
  11. className,
  12. accessibilityLabel,
  13. modifier,
  14. ...rest
  15. }: IconProps) {
  16. const iconClassName = classNames('material-symbols', className, modifier)
  17. return (
  18. <>
  19. <span className={iconClassName} aria-hidden="true" {...rest}>
  20. {type}
  21. </span>
  22. {accessibilityLabel && (
  23. <span className={bsVersion({ bs5: 'visually-hidden', bs3: 'sr-only' })}>
  24. {accessibilityLabel}
  25. </span>
  26. )}
  27. </>
  28. )
  29. }
  30. export default MaterialIcon