Facet List
One facet of a filter sidebar: an attribute’s values with counts, to include or exclude from a search.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
label | string | — | The facet's title: the attribute it filters by. |
values | FacetValue[] | [] | The values. As an attribute, a JSON array of { value, label, count }. |
include | string[] | [] | The values included. As an attribute, values separated by ;. |
exclude | string[] | [] | The values excluded. As an attribute, values separated by ;. |
open | boolean | true | Whether the values are shown. |
searchable | boolean | false | Adds a field that filters the values. |
max-items | number | 0 | How many values show before a button reveals the rest. 0 shows them all. |
sort | 'count' | 'label' | 'none' | count | The order of the values: largest count first, by label, or as given. |
count-format | Intl.NumberFormatOptions | undefined | undefined | Intl.NumberFormat options for the counts, as an object or JSON. Defaults to the compact notation (12K). |
Events
| Name | Type | Description |
|---|---|---|
filter-change | CustomEvent<FacetFilterDetail> | The user changed the selection. detail is include and exclude as they are about to become. Cancelable. |
toggle | Event | The facet was opened or collapsed by the user. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
header | The row with the title and the Clear button. |
title | The title, a button that opens and collapses the facet. |
clear | The Clear button. |
search | The field that filters the values. |
value | One value's row. |
checkbox | A value's checkbox. |
label | A value's label. |
count | A value's count. |
action | The Only and Exclude buttons. |
toggle | The button that shows or hides the values past max-items. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-facet-list--font-size | font-size | 14px | |
--c2-facet-list--color | color | #18181b | |
--c2-facet-list__title--font-weight | font-weight | 600 | |
--c2-facet-list__header--padding | padding | 6px 4px | |
--c2-facet-list__value--height | pixel | 30px | |
--c2-facet-list__value--padding | padding | 0 4px | |
--c2-facet-list__value--border-radius | border-radius | 6px | |
--c2-facet-list__value__hover--background-color | color | #f4f4f5 | |
--c2-facet-list__count--color | color | #71717a | |
--c2-facet-list__count--font-size | font-size | 12px | |
--c2-facet-list__checkbox--size | pixel | 16px | |
--c2-facet-list__checkbox--border | border | 1px solid #bcbcc6 | |
--c2-facet-list__checkbox__selected--background-color | color | #476ef9 | |
--c2-facet-list__checkbox__mark--color | color | #ffffff | The check and the dash drawn on a selected checkbox. |
--c2-facet-list__excluded--color | color | #dc2626 | The excluded value's checkbox and label. |
--c2-facet-list__action--size | pixel | 24px | |
--c2-facet-list__action--color | color | #71717a | |
--c2-facet-list__action__hover--background-color | color | #e4e4e7 | |
--c2-facet-list__search--border | border | 1px solid #bcbcc6 | |
--c2-facet-list__search--border-radius | border-radius | 6px | |
--c2-facet-list__link--color | color | rgb(2, 101, 220) | The Clear and Show all buttons. |
--c2-facet-list__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under facet-list, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
label | Filter | — |
clear | Clear | — |
clearLabel | Clear {0} | {0} facet |
search | Filter values | — |
onlyText | Only | — |
only | Only {0} | {0} value |
exclude | Exclude {0} | {0} value |
include | Include {0} | {0} value |
valueName | {0}, {1} | {0} value {1} count |
excluded | {0}, excluded | {0} name |
showAll | Show all {0} | {0} count |
showFewer | Show fewer | — |
noMatches | No values match | — |