Skip to content
Calm motion: animations on this site only fade, with no movement

Facet filter ​

Filters for a catalog, with counts, a price range, and clear buttons

Narrows a list of products in the side column of a shop. A facet is one property of the products, such as the brand. For filters as chips in a toolbar, use the filter bar.

Basic
Filters
Type
Pickup pattern
Price
  • facets is a list of facets. Each facet has an id, a label, and options. Each option has a value, a label, and an optional count.
  • v-model holds the chosen values of each facet, by facet id, such as { type: ["usb"] }.
  • Each facet is a fieldset of native check boxes. If an option has a count of 0, its check box is off, unless it is already checked.
  • A facet with a checked option gets a Clear button. "Clear all" at the top shows the number of active filters and clears them all.
  • With priceRange, a price facet with two number fields shows. v-model:price is [lowest, highest], and an empty field is undefined. currency and locale give the currency symbol.
  • Give the new counts from your search after each change.
  • Change the words with labels or a label pack: title, price, min, max, clear, and clearAll (a function).

Usage ​

ts
import { BlessFacetFilter } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
facets*BlessFacet[]—
priceRangeboolean—show a price range with two fields
currencystring"USD"
localestring"en"
labelsPartial<{ title: string; price: string; min: string; max: string; clear: string; clearAll: (count: number) => string; }>—
modelValueRecord<string, string[]>{}the chosen values of each facet, by facet id
price[number | undefined, number | undefined][undefined, undefined][lowest, highest]; an empty end is undefined

Events

NamePayloadDescription
update:modelValue[value: Record<string, string[]>]
update:price[value: [number | undefined, number | undefined]]

Released under the MIT License. Character names and artwork belong to their owners.