Switching sets
Three libraries that all answer the same four names. The tags below carry no library attribute, so they follow whatever use() last set.
register('lucide', {
resolver: (name) => `https://cdn.jsdelivr.net/npm/lucide-static/icons/${name}.svg`,
})
register('material', {
className: 'material',
glyphs: {
search: 'search',
star: 'star',
bell: 'notifications',
home: 'home',
},
})
const EMOJI = {
search: '🔍',
star: '⭐',
bell: '🔔',
home: '🏠',
}
register('emoji', {
resolveSync: ({ name }) => ({ tag: 'span', text: EMOJI[name] }),
})
use('lucide')
<ml-sigil-icon name="search"></ml-sigil-icon>
<ml-sigil-icon name="star"></ml-sigil-icon>
<ml-sigil-icon name="bell"></ml-sigil-icon>
<ml-sigil-icon name="home"></ml-sigil-icon>
Loading…
Nothing about the markup changes. A publisher script, a theme toggle or a settings screen can call use() and every icon on the page follows.
Pinning a library
An icon with a library attribute ignores use() - it always asks that one library. Pin as a guest embedded on pages you don't control - a player, a widget, a shared library - so a host's use() can never blank its icons; only a scoped override or registering under its name reaches it. A scoped override can't collide with a host's own unscoped override of the same name, so the name itself needs no prefix. @munsonlabs/video-player does exactly this.
Your own page's icons, by contrast, should follow use() rather than pin, so a customisation script never needs to know your library names. A single logo or brand mark can pin the same way, or simpler, be an override.
The test: if the page's default library changed and this icon changed with it, would that be a bug? If yes, pin.
library binds like any prop - <Sigil name="save" :library="cardLibrary" /> gives one group its own switch, independent of use(). For a page-wide switch, prefer use() itself: it's already global and reaches every renderer, including <ml-sigil-icon> and other bundles.