el.xwx.moe/components/Icon.tsx

19 lines
436 B
TypeScript
Raw Normal View History

import React, { forwardRef } from "react";
import * as Icons from "@phosphor-icons/react";
type Props = {
icon: string;
} & Icons.IconProps;
const Icon = forwardRef<SVGSVGElement, Props>(({ icon, ...rest }, ref) => {
const IconComponent: any = Icons[icon as keyof typeof Icons];
if (!IconComponent) {
return null;
} else return <IconComponent ref={ref} {...rest} />;
});
2024-09-04 21:29:54 -05:00
Icon.displayName = "Icon";
export default Icon;