Skip to content

Instantly share code, notes, and snippets.

@ascorbic
Last active January 2, 2020 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ascorbic/c7ed769c52baee89374d1c53b8c867b2 to your computer and use it in GitHub Desktop.
Save ascorbic/c7ed769c52baee89374d1c53b8c867b2 to your computer and use it in GitHub Desktop.
IconSprite
import React, { FC, HTMLAttributes } from "react";
interface Props extends HTMLAttributes<SVGSVGElement> {
name: string;
width?: number | string;
height?: number | string;
}
export const IconSprite: FC<Props> = ({
name,
width = 50,
height = 50,
...props
}) => (
<svg
width={width}
height={height}
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<use xlinkHref={`#icon-${name}`} />
</svg>
);
export default IconSprite;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment