Skip to content
satin

Filter bar

Pro

One facet per field, always in the same place, each opening its own choices (checkboxes, presets, a date range), and the result count live as they change.

14 deals
DealOwnerStageValueClose
AcmeTara Mendes
Lead
€21,500Oct 3
GlobexTara Mendes
Qualified
€30,500Nov 8
InitechTara Mendes
Proposal
€39,500Dec 13
UmbrellaTara Mendes
Negotiation
€48,500Oct 18
StarkTara Mendes
Won
€57,500Nov 23

9 more deals

Installation

Terminal
npm i @uisatin/ui @uisatin/pro
Import
import '@uisatin/ui/styles.css'
import '@uisatin/pro/styles.css'
import { FilterBar, applyFilters, type Filter, type FilterField } from '@uisatin/pro/filter-bar'

Part of Satin Pro, the licensed edition: @uisatin/pro on top of @uisatin/ui at the same version, its stylesheet after Free's. Satin Pro isn't on npm yet.

About 7.4 kB of JavaScript, minified and gzipped, on top of the @uisatin/uicomponents it uses (React aside).

First time with Satin? Set it up once, styles and fonts included, with the installation guide.

API Reference

The FilterBar component (Satin Pro, @uisatin/pro/filter-bar) is a role="group" with one facet per field, each in a fixed place: idle it shows the field's label ("Stage"), set its value and a × ("Owner: Me"). There is no "+ Filter" and no operator to pick; a facet opens its choices. enum, person and multi fields open a menu of checkboxes that stays open: one pick writes is, several isAnyOf, and multi always hasAnyOf. A person field lists its me first, as "Me". When an option has a tone, picks show as Badges, two at most, then "+N". A number field opens a menu of its presets (gt, gte, lt, lte or between, each with an optional label), shown compact through format. A date field opens its presets (a period for "This quarter", a number for "Last 30 days"; by default this month, quarter and year and the last 30 days) and Custom range…, a Calendar on the same surface. Each field is { key, label, shortLabel, type } plus options and me, or presets and format, or presets and customRange, by type. value is Filter[] ({ field, operator, value }, plain JSON, dates as YYYY-MM-DD), one filter per field; applyFilters(rows, value, fields, { getValue, today }) returns the rows it lets through, for a List, Table or DataGrid, and isFilterValid says whether a filter applies. A filter no facet can say leaves its facet idle and doesn't apply. Clear filters shows while a filter applies; the count shows with resultCount. Parts: FilterBarRoot, FilterBarFacet, FilterBarClear, FilterBarCount. Its words (filterFacetValue, filterFacetField, filterComparison, filterThis, filterLastDays, filterResults…) are translated with SatinLabels.

PropTypeDefault
fields
FilterField[]
—
value
Filter[]
—
defaultValue
Filter[]
[]
onValueChange
(value: Filter[]) => void
—
resultCount
number
—
resultLabel
(count: number, number: ReactNode) => ReactNode
—
container
HTMLElement | null
—
today
Date
—

Accessibility

A group named "Filters" (filterBar in SatinLabels). Each facet is a button with aria-haspopup and aria-expanded. Idle, it is named by its label ("Stage"); set, by the field and its value in full, "Stage: Lead or Qualified" (filterFacetValue), with numbers in words ("Value: over €20,000"). The name lists every pick, so the "+1" a set facet shows is not in it. The shown and the spoken words differ on purpose, which is WCAG 2.5.3 (label in name) territory: "Close: This quarter" is heard as "Close date: This quarter", and "Value: > €20k" as "Value: over €20,000". The name always starts with the field’s full label. The × beside a set facet is named "Clear Stage" (filterClearField) and leaves focus on the facet. Options and number facets open a menu named after the facet, of menuitemcheckbox or menuitemradio rows. A date facet opens a dialog named after the field, with its presets as a listbox that keeps focus while aria-activedescendant follows the highlight; Custom range… turns it into a dialog named "Custom range" with the Calendar, and the line over it ("Pick the first day") is a polite live region. Clear filters is an icon button named "Clear filters", there only while a filter applies; it moves focus to the first facet. The count is a polite live region read as a whole ("14 results"); the rolling digits are hidden from screen readers.

KeyAction
TabMoves through each facet, the × of a set one, then Clear filters. In the date surface: from the list to Clear, or from Back to the calendar.
EnterorSpaceor↓On a facet: opens its menu, or its date list on the picked row.
↑or↓In a menu or the date list: moves between rows. The date list wraps.
HomeorEndIn a menu or the date list: the first or the last row.
EnterorSpaceOn a checkbox row: turns it on or off; the menu stays open. On a number preset: picks it and closes the menu. On Clear: clears the facet and closes.
EnterorSpaceIn the date list: picks the highlighted preset and closes; on Custom range…, shows the Calendar, focus on its day. In the calendar: picks a day, and the second applies the range and closes.
←or→or↑or↓In the calendar: moves by day and by week, as on Date picker; Page Up and Page Down move by month.
EscIn the calendar: back to the list. Otherwise closes the menu or the date list, focus back on the facet.