@tola/icon

Render configured SVG icons inline in HTML or publish them as standalone SVG assets.

Import

typst
#import "@tola/icon:0.0.0": *

Icons whose fill or stroke uses currentColor automatically inherit surrounding text color when rendered inline with icon(...); explicit colors in the SVG stay unchanged.

Exports

icon

typc
let icon(
  id: string,
  attrs: dictionary = (:),
  label: none | string = none,
  module: none | string = none,
) = content;

Insert a configured icon as a 1em inline SVG inside HTML documents.

Validates id at call time. Works only in HTML documents; for PDF or other formats use icon-bytes or icon-url.

Positional parameters

  • id string required: Case-sensitive "namespace:name" identifier declared under [icons.collections].

Named parameters

  • module none | string default: none: Optional module alias owning the collection. Omit to use site collections.
  • label none | string default: none: Accessible label for screen readers (non-blank). Omit or pass none to mark the icon decorative (aria-hidden="true").
  • attrs dictionary default: (:): Extra string-valued attributes on the root <svg> (for example (class: "brand",)). class and style append; accessibility attributes (aria-label, aria-labelledby, aria-hidden, role, focusable) are managed by label and rejected in attrs.

Render decorative and labeled inline icons

typst
#import "@tola/icon:0.0.0": icon

#document("index.html")[
  #icon("brand:mark")
  #icon("brand:mark", label: "Site logo", attrs: (class: "brand",))
]

icon-bytes

typc
let icon-bytes(
  id: str,
  module: str | none = none,
) = bytes;

Return the raw SVG bytes of a configured icon for Typst image(...) or custom asset(...) publishing.

Positional parameters

  • id str required: Case-sensitive "namespace:name" icon identifier.

Named parameters

  • module str | none default: none: Optional module alias owning the collection. Omit to use site collections.

icon-url

typc
let icon-url(
  id: str,
  module: str | none = none,
) = str;

Publish a configured icon as a standalone SVG file and return its browser URL (with site.base-path).

Only icons referenced during evaluation are published.

Positional parameters

  • id str required: Case-sensitive "namespace:name" icon identifier.

Named parameters

  • module str | none default: none: Optional module alias owning the collection. Omit to use site collections.

Load a published icon with `<img>`

typst
#import "@tola/icon:0.0.0": icon-url

#document("index.html")[
  #html.img(src: icon-url("brand:mark"), alt: "Site mark")
]

Search this site

Use the arrow keys to move through results.

Type to search.