@jugar/svg-icon
v0.0.4
Published
A SVG Symbol Manager Tool
Downloads
85
Readme
How to use svg-icon
- Installation
npm install @jugar/svg-icon
Local
Register SVG Icon by Name
import { defineLoader, registerSymbol } from '@jugar/svg-icon'
defineLoader((fullname: string) => {
const [dir, name] = fullname.split(':')
// relative to the current directory
return new URL(`../../svg/${dir}/${name}.svg?url`, import.meta.url).href
})
registerSymbol('dir:name')
- Use SVG Icon by Name
<svg class="svg-icon">
<use xlink:href="#dir:name" />
</svg>