guide

Icon Resolution

How $icons resolves keys through page-level and instance-level repositories before built-ins.

Components render icons by key. Provide your own SVGs in a <template data-fn="icons"> inside the component, keyed with data-key. Options reference them with data-icon.

<button type="button" class="z-button z-button-secondary" data-toggle="#cmd-icons-guide">Open palette</button>

<z-cmd id="cmd-icons-guide">
  <select data-fn="data-source" hidden>
    <optgroup label="Actions">
      <option value="run" data-icon="play">Run</option>
    </optgroup>
  </select>
  <template data-fn="icons">
    <svg data-key="play" viewBox="0 0 24 24" fill="currentColor">
      <path d="M8 5v14l11-7z"></path>
    </svg>
  </template>
</z-cmd>

A page-level repository serves every component on the page:

icons/snippet-page.html
<template id="z-icons">
  <svg data-key="play" viewBox="0 0 24 24" fill="currentColor">
    <path d="M8 5v14l11-7z"></path>
  </svg>
</template>