guide

The data-source Convention

Components read options from a hidden select: groups, values, and data-* configuration.

Data-driven components read a hidden <select data-fn="data-source"> placed inside them. Optgroups become groups, options become items, and data-* attributes on options carry extra configuration.

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

<z-cmd id="cmd-data-source">
  <select data-fn="data-source" hidden>
    <optgroup label="Documents">
      <option value="report" data-keywords="quarterly, finance" data-description="Q4 summary" data-kbd="⌘+R">
        Report
      </option>
      <option value="invoice" data-icon="book">Invoice</option>
    </optgroup>
    <option value="scratch">Scratch pad</option>
  </select>
</z-cmd>
Option attributeMeaning
valueIdentifier emitted in select events.
disabledNon-selectable; skipped by keyboard navigation.
selectedInitially selected.
data-keywordsExtra comma-separated search terms.
data-descriptionSecondary line under the label; also searched.
data-iconIcon key resolved through the icon repositories.
data-kbdKeycap hint: + joins keys, spaces separate them.
data-shortcutAlternative keycap hint when data-kbd is absent.