Getting Started
Introduction
A tiny icon registry - register a library, render icons by name, swap them at runtime.
@munsonlabs/sigil turns icon names into markup. Describe where icons come from once, then render them anywhere by name.
import { register, override, use } from '@munsonlabs/sigil'
import '@munsonlabs/sigil/element'
register(
'lucide',
{
resolver: (name) => `https://cdn.jsdelivr.net/npm/lucide-static/icons/${name}.svg`,
},
{ default: true },
)
register('fa', {
className: 'fa',
mapping: { heart: 'fa-heart' },
})
override('logo', '<svg viewBox="0 0 24 24">…</svg>')
<ml-sigil-icon name="rocket"></ml-sigil-icon>
<ml-sigil-icon name="heart" library="fa"></ml-sigil-icon>
<ml-sigil-icon name="logo"></ml-sigil-icon>
What you get
| Register with | You get |
|---|---|
{ resolver } | SVGs fetched by name from any URL, string or import |
{ className, mapping } | A CSS icon font |
{ resolveSync, resolve } | Anything you can write yourself |
Anything else - a JSON file, an API - is a few lines with { resolver }. Render with <ml-sigil-icon> in any framework, or <Sigil> in Vue. Icons registered later, even by a separate script, update in place.
Live
Loading…
Loading…
Loading…