Created
March 31, 2023 10:24
-
-
Save davidramos-om/895b50d15ae5d74c60e27ba9c8187c26 to your computer and use it in GitHub Desktop.
Iconify - Working with icons from icon-sets.iconify (Chakra UI Version)
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 { Icon } from '@iconify/react'; | |
import { Box, BoxProps, useColorMode, useToken } from '@chakra-ui/react' | |
interface Props extends BoxProps { | |
icon: string; | |
rotate?: number; | |
width?: number; | |
height?: number; | |
color?: string; | |
} | |
//* We can get the icon code from https://iconify.design/icon-sets/ | |
//* For example, one icon code for the "home" could be "mdi:home" | |
export default function SvgIconify({ icon, sx, rotate = 180, width = 24, height = 24, color, ...others }: Props) { | |
const { colorMode } = useColorMode(); | |
const [ light, dark ] = useToken('colors', [ 'gray.600', 'gray.500' ]); | |
return ( | |
<Box | |
{...others} | |
> | |
<Icon | |
icon={icon} | |
rotate={rotate} | |
width={width} | |
height={height} | |
color={color ? color : (colorMode === 'light' ? light : dark)} | |
/> | |
</Box> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment