Skip to main content
useIcon Hook
Diego Muralles avatar
Written by Diego Muralles
Updated over a week ago

Watches and returns information about an icon given its icon key. The icon key can be created/found in the widget’s manifest file.

For SVG icons the following information is returned:

  • width - the width of the SVG viewbox

  • height - the height of the SVG viewbox

  • path - the SVG path to render the icon

Usage

const iconInfo: [ number, number, string | string[] ] = useIcon( iconKey: string );

Example

Render an icon

import { useIcon } from 'vev';

export default function() {
const [width, height, ...path] = useIcon('smiley-icon');

return (
<svg viewBox={`0 0 ${width} ${height}`}>
{path.map((d,index) => <path key={index} d={d} />)}
</svg>
);
}

Did this answer your question?