Search
The glass search pill. Pair it with a menu underneath for suggestions.
| Name | Type | What it does |
|---|---|---|
search | component | A <label> holding an icon, an <input> and an optional clear button |
data-filter="#list-id" | part | With behaviors.js loaded: on the input. Hides the <li>s of that list that do not contain what is typed |
data-clear | part | With behaviors.js loaded: on the button. Empties the field |
Filtering a list already on the page needs behaviors.js. Searching a server is yours to write: listen for the input event and fill the menu.
Search with results
<div style="display: grid; gap: 0.625rem; width: min(26rem, 100%)">
<label class="search glow">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
<input type="search" placeholder="Type to filter" aria-label="Search" data-filter="#search-results">
<button class="btn btn-ghost btn-circle btn-sm" type="button" aria-label="Clear" data-clear><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 6 12 12M18 6 6 18"/></svg></button>
</label>
<ul class="menu glass glow" id="search-results">
<li><a href="#"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="m3 16 5-5 4 4 3-3 6 6"/></svg> Photos <span class="meta">2,418</span></a></li>
<li><a href="#"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 21s7-6.2 7-11a7 7 0 1 0-14 0c0 4.800 7 11 7 11z"/><circle cx="12" cy="10" r="2.500"/></svg> Places <span class="meta">36</span></a></li>
<li><a href="#"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="5" width="16" height="14" rx="2"/><path d="M8 10h8M8 14h8"/></svg> Stories <span class="meta">112</span></a></li>
</ul>
</div>