Icon picker
Choose one Phosphor icon for a space, circle or document.
Full set
Select the icon to open the picker. The current icon is selected, search matches names and tags (try “home” or “money”), and arrow keys move across the grid. Choosing an icon closes the picker. Remove clears the value.
Subset with ghost tiles
Your application renders only the icons it allows. This example offers 16 circle icons, has no value yet and uses .icon-picker--ghost on the picker and .button--ghost on the trigger to remove the resting borders.
<div class="icon-picker" data-icon-picker>
<button type="button" class="button button--subtle button--icon icon-picker-trigger" popovertarget="space-panel" aria-label="Change icon, House">
<span class="icon-picker-current"><svg class="icon" aria-hidden="true" focusable="false" fill="currentColor"><use href="/icons/phosphor-bold.svg#house"/></svg></span>
<span class="icon-picker-placeholder" hidden><svg class="icon" aria-hidden="true" focusable="false" fill="currentColor"><use href="/icons/phosphor-bold.svg#selection-plus"/></svg></span>
</button>
<div class="icon-picker-panel" id="space-panel" popover>
<fieldset class="icon-picker-fieldset" aria-labelledby="space-heading">
<div class="icon-picker-header">
<h3 class="icon-picker-heading" id="space-heading">Icons</h3>
<label class="icon-picker-remove button button--ghost button--small">
<input type="radio" name="icon" value="" class="visually-hidden">Remove
</label>
</div>
<div class="icon-picker-search" hidden>
<label class="visually-hidden" for="space-search">Filter icons</label>
<input type="search" class="input--small" id="space-search" placeholder="Filter icons…" autocomplete="off">
</div>
<div class="icon-picker-body">
<section class="icon-picker-section icon-picker-recent" hidden>
<h4 class="icon-picker-section-heading">Recent</h4><div class="icon-picker-grid"></div>
</section>
<section class="icon-picker-section" aria-labelledby="space-maps">
<h4 class="icon-picker-section-heading" id="space-maps">Maps & travel</h4>
<div class="icon-picker-grid">
<label class="icon-picker-tile" title="House" data-tags="homes buildings places locations">
<input type="radio" name="icon" value="house" class="visually-hidden" checked>
<svg class="icon" aria-hidden="true" focusable="false" fill="currentColor"><use href="/icons/phosphor-bold.svg#house"/></svg>
<span class="visually-hidden">House</span>
</label>
<!-- One label per icon in the configured set -->
</div>
</section>
</div>
<p class="icon-picker-status" role="status" aria-atomic="true" hidden></p>
</fieldset>
</div>
</div>
<script type="module">
import { createIconPicker } from '/dist/icon-picker.js';
const picker = createIconPicker({ root: document.querySelector('[data-icon-picker]') });
// After replacing tiles in place: picker.refresh(). Before removing the root: picker.dispose().
</script>Contract
- Value
- The checked radio submits a Phosphor name such as
users-three. Remove submits an empty value. - Subsets
- Render only the allowed icons, chosen by name list, Phosphor category or exclusions. Validate the submitted name on the server against the same list.
- Icons
- Tiles reference
/icons/phosphor-bold.svg, generated withnpm run iconsfrom@phosphor-icons/core./icons/phosphor-catalog.jsonlists each name’s category and search tags. - Without JavaScript
- The trigger opens the native popover and the radios submit with the form. Search, Recent and the count stay hidden, and the trigger updates after saving.
- Script
createIconPicker({ root, recent, recentKey, recentLimit })returnsrefresh()anddispose(). Recent is stored inlocalStorage. Saving belongs to your application.