PhoenixIconify (PhoenixIconify v0.3.0)

Copy Markdown View Source

Phoenix components for Iconify icons with compile-time discovery.

Summary

Functions

Gets icon data by name.

Renders an icon as an inline SVG.

Checks if an icon exists in the manifest.

Lists all available icon names from the manifest.

Normalizes icon names to the canonical Iconify format.

Functions

get_icon(name)

Gets icon data by name.

icon(assigns)

Renders an icon as an inline SVG.

Examples

<.icon name="lucide:settings" class="size-5" />
<.icon name="hero-user" class="size-6 text-zinc-500" />
<.icon name="mdi:account" label="Account" />
<.icon name="lucide:x" phx-click="close" />

Attributes

  • name (:string) (required) - Icon name (for example, lucide:settings).
  • class (:string) - CSS classes. Defaults to nil.
  • label (:string) - Accessible label. Makes the SVG role=img. Defaults to nil.
  • title (:string) - Optional SVG title text. Defaults to nil.
  • size (:any) - Width and height to apply together. Defaults to nil.
  • width (:any) - SVG width attribute. Defaults to nil.
  • height (:any) - SVG height attribute. Defaults to nil.
  • color (:string) - CSS color for currentColor icons. Defaults to nil.
  • inline (:boolean) - Align icon with text baseline. Defaults to false.
  • mode (:string) - Render mode: svg, mask, or bg. Defaults to "svg".
  • rotate (:integer) - Additional 90-degree rotations. Defaults to 0.
  • flip (:string) - Flip direction: horizontal, vertical, or both. Defaults to nil.
  • h_flip (:boolean) - Apply horizontal flip. Defaults to false.
  • v_flip (:boolean) - Apply vertical flip. Defaults to false.
  • Global attributes are accepted. Additional SVG attributes.

icon_exists?(name)

Checks if an icon exists in the manifest.

list_icons()

Lists all available icon names from the manifest.

normalize_name(name)

Normalizes icon names to the canonical Iconify format.