Toolbar and search

On this page

A toolbar sits above every table or grid. It holds the search box, filter chips or selects, and actions for the list as a whole, such as Export CSV.

A toolbar with search, filter chips and an export buttonA toolbar with search, filter chips and an export button

Figure 1: A toolbar with a search box, three filter chips (one on) and an action

<section class="ph-card ph-card--flush">
  <div class="ph-toolbar">
    <label class="ph-search">
      <span class="ph-visually-hidden">Search customers</span>
      <svg class="ph-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
           stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8" /><path d="m21 21-4.3-4.3" /></svg>
      <input class="ph-input" type="search" placeholder="Search customers" />
    </label>
    <button type="button" class="ph-chip" aria-pressed="true">Active</button>
    <button type="button" class="ph-chip" aria-pressed="false">On hold</button>
    <div class="ph-toolbar-actions">
      <button type="button" class="ph-btn">Export CSV</button>
    </div>
  </div>
  <div class="ph-table-wrap">...</div>
</section>
ClassWhat it is
.ph-toolbarThe row of controls above a table
.ph-toolbar-actionsPushes its contents to the right end of the toolbar
.ph-searchA search box with an icon (up to 280px wide)
.ph-chipA filter toggle. Dashed when off, blue when aria-pressed="true".

Behaviour

Chips are toggles you control: flip aria-pressed in your click handler, then filter.

chip.addEventListener('click', () => {
  chip.setAttribute('aria-pressed', String(chip.getAttribute('aria-pressed') !== 'true'));
  applyFilters();
});
  • Wait 250 ms after the last keystroke before searching (debounce), so typing stays smooth.
  • For kit tables, filter by setting data-ph-hide on rows that don't match. See Tables.
  • The data grid can take the search box directly (search: '#customer-search').

React

import { Toolbar, SearchField, FilterChip } from 'ph-app-kit-react';

<Toolbar
  search={<SearchField value={query} onChange={setQuery} />}
  filters={<FilterChip label="Status" value={status} onChange={setStatus} options={STATUS_OPTIONS} />}
  actions={<StyledButton onClick={exportCsv}>Export CSV</StyledButton>}
/>

Guidelines

  • The search placeholder says what it searches: "Search customers".
  • Label the search input for screen readers (the .ph-visually-hidden span).
  • Put bulk actions in a menu at the right of the toolbar when there are more than two.
  • Show "Clear filters" in the empty state when filters hide every row.