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
facetsis a list of facets. Each facet has anid, alabel, andoptions. Each option has avalue, alabel, and an optionalcount.v-modelholds 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:priceis[lowest, highest], and an empty field isundefined.currencyandlocalegive the currency symbol. - Give the new counts from your search after each change.
- Change the words with
labelsor a label pack:title,price,min,max,clear, andclearAll(a function).
Usage
ts
import { BlessFacetFilter } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
facets* | BlessFacet[] | — | |
priceRange | boolean | — | show a price range with two fields |
currency | string | "USD" | |
locale | string | "en" | |
labels | Partial<{ title: string; price: string; min: string; max: string; clear: string; clearAll: (count: number) => string; }> | — | |
modelValue | Record<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
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: Record<string, string[]>] | |
update:price | [value: [number | undefined, number | undefined]] |