material-icon.tsx 748 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import classNames from 'classnames'
  2. import React from 'react'
  3. type IconOwnProps = {
  4. type: string
  5. category?: 'rounded' | 'outlined'
  6. accessibilityLabel?: string
  7. }
  8. type IconProps = IconOwnProps &
  9. Omit<React.ComponentProps<'i'>, keyof IconOwnProps>
  10. function MaterialIcon({
  11. type,
  12. category = 'rounded',
  13. className,
  14. accessibilityLabel,
  15. ...rest
  16. }: IconProps) {
  17. const iconClassName = classNames(
  18. 'material-symbols',
  19. `material-symbols-${category}`,
  20. className
  21. )
  22. return (
  23. <>
  24. <span className={iconClassName} aria-hidden="true" {...rest}>
  25. {type}
  26. </span>
  27. {accessibilityLabel && (
  28. <span className="sr-only">{accessibilityLabel}</span>
  29. )}
  30. </>
  31. )
  32. }
  33. export default MaterialIcon