Converts an SVG string to data url. This is useful for creating images from SVGs, or using SVGs in CSS. To use put in template string: url(${svgUrl`<svg>...</svg>`})
url(${svgUrl`<svg>...</svg>`})
const url = svgUrl` <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> ... </svg>`console.log(url) // data:image/svg+xml;charset=UTF-8,... Copy
const url = svgUrl` <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> ... </svg>`console.log(url) // data:image/svg+xml;charset=UTF-8,...
template strings
template values
Converts an SVG string to data url. This is useful for creating images from SVGs, or using SVGs in CSS. To use put in template string:
url(${svgUrl`<svg>...</svg>`})
Example