Files
web/packages/design-system/lib/components/Icons/MaterialIcon/MaterialIcon.tsx
Erik Tiekstra 8d34e1c8bb fix(SW-2101): Avoid underline on icons
Approved-by: Linus Flood
2025-04-07 10:38:00 +00:00

30 lines
830 B
TypeScript

import {
MaterialSymbol,
type MaterialSymbolProps,
} from 'react-material-symbols'
import { iconVariants } from '../variants'
import type { VariantProps } from 'class-variance-authority'
export interface MaterialIconProps
extends Pick<MaterialSymbolProps, 'size' | 'icon' | 'className' | 'style'>,
VariantProps<typeof iconVariants> {
isFilled?: boolean
}
export type MaterialIconSetIconProps = Omit<MaterialIconProps, 'icon'>
export function MaterialIcon({
color,
className,
isFilled = false,
...props
}: MaterialIconProps) {
const classNames = iconVariants({ className, color })
return (
// The span is used to prevent the MaterialSymbol from being underlined when used inside a link or button
<span>
<MaterialSymbol className={classNames} {...props} fill={isFilled} />
</span>
)
}