Server-side SVG icons (Hugeicons Stroke Rounded), no JavaScript needed.
<.icon name="download" />
<.icon name="huge-download-01" size="sm" class="muted" />
<.icon name="check-circle" boxed tone="success" />The output is identical to what LedgerUI.hydrate() produces from <i data-i="name">:
<svg class="lu-i sm" viewBox="0 0 24 24" aria-hidden="true" data-icon="download">...</svg>Every icon is precomputed at compile time from priv/icons.json (regenerate it with
elixir scripts/extract_icons.exs) as an iodata binary and emitted with Phoenix.HTML.raw/1,
so rendering costs one map lookup.
Names
Dictionary keys (download, chevron-down, ...) are used as-is. The API's huge-* names
are accepted too: huge- (or hugeicons:) is stripped, then the exact key is tried, then
the key without a trailing -NN suffix (huge-download-01 -> download-01 -> download).
Unknown names render nothing and log a warning (disable with
config :ledger_ui, warn_unknown_icons: false).
Vendored icons
Icons outside the dictionary come from the app's own folder, filled by mix ledger_ui.icons
(get, sync; see LedgerUI.Icons):
config :ledger_ui, :icons_path, "priv/hugeicons"
<.icon name="huge-invoice-01" />They are loaded once into :persistent_term and render the same markup as the built-in ones.
Order of lookup: a built-in key (exact, after dropping huge-), then a vendored file of that
name, then the built-in key without its -NN suffix. So a built-in name always wins over a
vendored file of the same name, while huge-download-01 finds the vendored download-01.svg
before settling for the built-in download.
Box
boxed wraps the icon in the lu-ic box; tone colours it (accent/acc, success/pos,
error/neg, warning/warn, info, lime, neutral). box_size="lg" gives the large
box; any number of pixels sets width/height inline. The inner block replaces name.
Summary
Functions
Whether name (with or without huge-) is a key of the built-in dictionary.
Names of all icons in the built-in dictionary.
Resolves an API name to a dictionary key (see module docs), or nil.
Functions
Whether name (with or without huge-) is a key of the built-in dictionary.
mix ledger_ui.icons sync skips these: they need no download.
Attributes
name(:string) - Icon name (dictionary key orhuge-*). Defaults tonil.size(:string) - Defaults tonil.Must be one ofnil,"sm","md","lg", or"xl".class(:any) - Defaults tonil.boxed(:boolean) - Wraps the icon in thelu-icbox. Defaults tofalse.tone(:string) - Box colour (needsboxed). Defaults tonil. Must be one ofnil,"acc","accent","error","info","lime","neg","neutral","pos","success","warn", or"warning".box_size(:any) -"lg"or a size in pixels. Defaults tonil.box_class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block- Own SVG inside the box, instead ofname.
Names of all icons in the built-in dictionary.
Resolves an API name to a dictionary key (see module docs), or nil.
iex> LedgerUI.Components.Icon.resolve("huge-download-01")
"download"
iex> LedgerUI.Components.Icon.resolve("nope")
nil