Last active
January 16, 2023 10:12
-
-
Save aleyrizvi/036b05e948307c28affdb4e16045f2dc to your computer and use it in GitHub Desktop.
Dynamic Tabler Icons import for react
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as icons from "@tabler/icons" | |
interface Props { | |
icon: string | |
color?: string | |
size?: number | |
stroke?: number | |
} | |
export const TablerIcons = (props: Props): JSX.Element => { | |
const { icon, color = "gray", size = 6, stroke = 2 } = props | |
// @ts-ignore | |
const Icon: JSX.Element = icons[icon] | |
return ( | |
// @ts-ignore | |
<Icon width={size} color={color} stroke={stroke} /> | |
) | |
} | |
// usage | |
<TablerIcons icon={"IconBrandAmazon"} color={"..."} size={"..."} stroke={...} /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment