4.3k

Icon

A vector icon leaf: name selects the icon, tint comes from the foreground color token, and size from width/height (square by default). A bare literal name is one of the curated built-in stroke icons — the markup compiler and the Zig builder both validate it at comptime against the registry, so icon references never rot. The same grammar powers the inline icon attribute on button, toggle-button, list-item, menu-item, and badge, where the icon draws as part of the control's single hit target.

icon
Built-in vector icons rendered by the engine (light theme)
a row of registry icons at the default size and tint

Markup

<row gap="20" cross="center">
  <icon name="play"></icon>
  <icon name="search" foreground="text_muted"></icon>
  <icon name="git-branch" width="28" height="28"></icon>
  <icon name="check-circle" foreground="success"></icon>
</row>

App icons and bound names

Two more value forms open the vocabulary without weakening it:

  • app:<name> draws an icon the app registered at boot with canvas.icons.registerAppIcons (comptime-parse the SVG with canvas.svg_icon.parseComptime). Declare the table as pub const app_icons on the app root and pass it to registerAppIcons in main — the model contract carries the same names, so native check verifies every app: reference against exactly what the app registers (with a did-you-mean). Without a fresh contract artifact the check degrades to structural checking and says so.
  • icon="{binding}" defers the choice to model data — a field or function producing a built-in name or an app: name per row (a status icon per item, a play/pause toggle). The contract checks the binding resolves to a string.

Both forms resolve at draw time with an honest failure mode: a name that resolves nowhere renders the missing-icon fallback (a slashed circle) and logs a Debug warning naming the value — visible and loud, never a silent gap.

<icon name="app:waveform" foreground="text_muted"></icon>
<button icon="{playPauseIcon}" on-press="toggle_play" label="Play or pause"></button>

Zig builder

ui.icon takes the name as a comptime argument — an unknown name is a compile error pointing at canvas.icons.known_icon_names.

ui.row(.{ .gap = 20, .cross = .center }, .{
    ui.icon(.{}, "play"),
    ui.icon(.{ .style_tokens = .{ .foreground = .text_muted } }, "search"),
    ui.icon(.{ .width = 28, .height = 28 }, "git-branch"),
    ui.icon(.{ .style_tokens = .{ .foreground = .success } }, "check-circle"),
})

Registry

The full built-in set (canvas.icons.known_icon_names), rendered by the engine.

The alert icon (light theme)
alert
The archive icon (light theme)
archive
The arrow-down icon (light theme)
arrow-down
The arrow-right icon (light theme)
arrow-right
The arrow-up icon (light theme)
arrow-up
The check icon (light theme)
check
The check-circle icon (light theme)
check-circle
The chevron-down icon (light theme)
chevron-down
The chevron-left icon (light theme)
chevron-left
The chevron-right icon (light theme)
chevron-right
The chevron-up icon (light theme)
chevron-up
The circle-dot icon (light theme)
circle-dot
The clock icon (light theme)
clock
The copy icon (light theme)
copy
The download icon (light theme)
download
The edit icon (light theme)
edit
The ellipsis icon (light theme)
ellipsis
The external-link icon (light theme)
external-link
The eye icon (light theme)
eye
The file-text icon (light theme)
file-text
The folder icon (light theme)
folder
The folder-open icon (light theme)
folder-open
The git-branch icon (light theme)
git-branch
The git-merge icon (light theme)
git-merge
The git-pull-request icon (light theme)
git-pull-request
The info icon (light theme)
info
The menu icon (light theme)
menu
The moon icon (light theme)
moon
The music icon (light theme)
music
The panel-left icon (light theme)
panel-left
The panel-right icon (light theme)
panel-right
The pause icon (light theme)
pause
The play icon (light theme)
play
The plus icon (light theme)
plus
The refresh-cw icon (light theme)
refresh-cw
The repeat icon (light theme)
repeat
The save icon (light theme)
save
The search icon (light theme)
search
The send icon (light theme)
send
The settings icon (light theme)
settings
The shuffle icon (light theme)
shuffle
The skip-back icon (light theme)
skip-back
The skip-forward icon (light theme)
skip-forward
The sun icon (light theme)
sun
The terminal icon (light theme)
terminal
The trash icon (light theme)
trash
The volume icon (light theme)
volume
The wrench icon (light theme)
wrench
The x icon (light theme)
x
The x-circle icon (light theme)
x-circle

Attributes

name is the icon element's own required attribute: a comptime-validated built-in name, an app:<name> reference to a registered app icon, or one {binding} resolving to such a name (not part of the shared attribute vocabulary). The rest are the shared sizing and tint attributes:

AttributeDescription
widthDefinite width (plain number): the element is exactly this wide; content neither shrinks nor overflows it. On resizable it is the initial width.
heightDefinite height (plain number): the element is exactly this tall; content neither shrinks nor overflows it.
foregroundForeground/text color token (literal ColorTokens field name, e.g. text, text_muted, success, warning, info).
labelAccessible name; when set it REPLACES the element's text as the announced name - screen readers and automation snapshots see the label, never the text it shadows.