Integrations

Other frameworks

React, Svelte, plain DOM.

<ml-sigil-icon> is a standard custom element; render it like any tag.

import '@munsonlabs/sigil/element'

export const Heart = ({ active }) => <ml-sigil-icon name="heart" variant={active ? 'active' : undefined} />

Without the element

watchIcon is what <ml-sigil-icon> and <Sigil> are built on: it resolves synchronously when it can, asynchronously otherwise, runs again whenever the registry changes, and drops results that arrive late. Reach for it directly when you don't want a custom element in the tree at all - a design system that wants a real <span>/<i>, SSR without a hydration mismatch to worry about, or a node you don't control as a component.

import { useEffect, useState } from 'react'
import { watchIcon } from '@munsonlabs/sigil'
import type { IconQuery, ResolvedIcon } from '@munsonlabs/sigil'

interface IconProps {
  name: string
  library?: string
  variant?: string
}

export function Icon({ name, library, variant }: IconProps) {
  const [icon, setIcon] = useState<ResolvedIcon>()

  useEffect(() => {
    const query: IconQuery = { library, variant }
    return watchIcon(name, query, setIcon) // watchIcon's return value is already the cleanup function
  }, [name, library, variant])

  if (!icon) return null

  const Tag = icon.tag as keyof JSX.IntrinsicElements
  return icon.html !== undefined ? (
    <Tag className={icon.className} aria-hidden="true" dangerouslySetInnerHTML={{ __html: icon.html }} />
  ) : (
    <Tag className={icon.className} aria-hidden="true">
      {icon.text}
    </Tag>
  )
}
<Icon name="bookmark" library="mlv" variant="active" />

Each framework's version re-subscribes whenever name/library/variant change and cleans up the old subscription first - React via the effect's dependency array, Svelte via the reactive statement re-running and stop?.() before it re-assigns. For a one-off lookup there are getIconSync(name, query) and getIcon(name, query); subscribe(listener) fires after every registry change.

munsonlabs · MIT licensed · © 2026