FilterChip
HkFilterChip is the facet member of the filter family: a chip trigger that opens a popover (a bottom sheet on mobile) holding a multi-select pill group — one category's alternatives, all in one place. The chip's own text mirrors the selection, so the page can read its filter state without opening anything.
- Reach for it when a page filters by a handful of enumerated facets side by side — provider, tier, region — where each one is a set of known values and picks within a set combine as OR. For free-form conditions use FilterTrigger and FilterPanel; for an always-visible row use FilterBar.
- The chip is not a toggle: toggle(value) reports one option flipped and all() reports the all-pill; the host decides whether "all" means clear or select-everything. Selected values never change here — selected is the single source of truth.
- The pill group itself is PillToggleGroup; this component adds the trigger, the label mirror and the popup.
Import
;
from "@celestia-island/hikari/components/HkPillToggleGroup";
use *; // FilterChip, FilterChipOption
use *; // FilterChipProps, rsx!, VNode, EventHandler
HkPillToggleGroupOption is not a root-barrel export — the named import from the package root fails (TS2305: Module '"@celestia-island/hikari"' has no exported member 'HkPillToggleGroupOption'), and the subpath import above is the spelling that resolves. The Rust form is FilterChip(FilterChipProps { … }); its option type is FilterChipOption (value, label, icon, trailing). Inside rsx! options, selected, hint, the three glyph seams and the handlers may be omitted; label and all_label are required.
The label mirror and the all-pill
The chip text is the allLabel when nothing is picked, otherwise the picked labels in canonical option order (not the order they were clicked), joined with commas and capped at three with a +N tail — a facet with twelve picks must not widen the strip. chipText overrides the mirror entirely for hosts whose chip says something else (a range corridor reads "VI – ★"); the accessible name follows the same rule: label alone with no picks, label: chipText once a selection or an override engages, so the visible state is never masked by a bare category name.
The leading "all" pill wears the active tint exactly when nothing is picked — "all" is a state, not an action. Pressing it emits all() and changes nothing by itself.
Selected: 4
All four are picked, so both cards read DeepSeek, OpenAI, Anthropic +1 and the chip wears its active face. Press the chip in the TSX card to open the pill group; the Rust card is a closed snapshot — no popover opens there.
The popup, the hints and the host's seams
Inside the popup, every pill is a role-less button with aria-pressed (the group is a role="group" named by label), and each pill may carry a leading glyph (icon) and a trailing glyph (trailing per option, allTrailing for the all pill). hint appends one line under the group — the facet's semantics ("multi-select", "clears the others") are the host's story to tell, not the component's. chipText overrides the mirror as described.
The host seams exist for the strip-level concerns that are not this component's job: the sort/direction arrows (renderChipTrailing on the trigger, renderPillTrailing(value) on each pill), the popup's content inset (padding, default lg because the popup holds content, not menu voices), and the outside-close (closeOnBackdrop) for bars that own their own dismissal.
Here the chip text is the explicit override This month, and the hint line sits under the pills. Both cards show this open frame — the TSX card because its open ref starts true, the Rust card because open: true is the only way a snapshot can open it. Close the TSX chip to see the collapsed trigger with the same override text.
Single-select facets, the Rust gaps and tone
A facet that must behave as single select is the host's rule, not the component's: read onToggle, then rebuild selected with just that one value (as the example above does). The pill group is multi-select by construction.
Rust gaps. The mirror has three: selected is a Vec<String> rather than a Set (membership is all the contract needs, and a Vec keeps the prop comparable); icon is an Element slot rather than a component or name the group resolves; and there is no tone channel — Vue's options[].tone / data-tone (the per-lane hue tint) has no counterpart, so the mirror emits data-active only. The vendored sheet's tone rules are inert in the Rust form rather than wrong.
There is also no mobile bottom-sheet branch in Rust: sheetOnMobile is a presentation Vue gets from its popover runtime, and the mirror keeps the anchored layer while the host decides the form factor.
Nothing is picked: the chip reads "All tiers" in its resting face and the all-pill would be the tinted one inside. The Rust card carries no padding — the inset is a Vue popover concern; the mirror's body is the sheet's own box.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| label | String | — | ✓ |
| allLabel | String | — | ✓ |
| options | Array as PropType<HkPillToggleGroupOption[]> | () => [] | — |
| selected | Object as PropType<Set<string>> | () => new Set<string>() | — |
| open | Boolean | false | — |
| placement | String as PropType<PopupPlacement> | "bottom-start" | — |
| hint | String | undefined | — |
| chipText | String | undefined | — |
| padding | String as PropType<HkPad> | "lg" | — |
| closeOnBackdrop | Boolean | true | — |
| renderChipTrailing | <code>Function as PropType<() => VNode | undefined></code> | undefined | — |
| renderPillTrailing | <code>Function as PropType<(value: string | null) => VNode | undefined></code> | undefined | — |
Emits
| Event | Payload |
|---|---|
| update:open | boolean |
| toggle | string |
| all | — |
Rust
Props — FilterChip
| Prop | Type | Default | Description |
|---|---|---|---|
| label | String | "" | Popup title + the trigger's accessible name (the category). |
| all_label | String | "" | Chip text with nothing picked, and the all-pill's label. |
| options | Vec<FilterChipOption> | [] | Facet values in canonical display order (also the chip-label order). |
| selected | Vec<String> | [] | The picked values — single source of truth, never mutated here. |
| open | bool | false | Popup visibility (Vue: the open prop + update:open emit). |
| placement | PopoverPlacement | PopoverPlacement::BottomStart | Layer placement against the anchor (Vue default "bottom-start"). |
| hint | Option<String> | None | Bottom hint line below the pill group. |
| chip_text | Option<String> | None | Chip-label override (Vue: chipText) — for hosts whose chip text is not the picked-label list (a range corridor). |
| trailing | Option<Element> | None | Trigger-suffix glyph (Vue: renderChipTrailing()) — the seat for the host's direction arrow; rendered UNWRAPPED after the text span, carrying its own classes. |
| all_trailing | Option<Element> | None | All-pill suffix glyph (Vue: renderPillTrailing(null)). |
| on_open_change | Option<EventHandler<bool>> | None | Fires with the desired open state (Vue: update:open). |
| on_toggle | Option<EventHandler<String>> | None | Fires with the toggled option value (Vue: toggle). |
| on_all | Option<EventHandler<()>> | None | Fires when the all-pill is activated (Vue: all). |
Accessibility
- The trigger is a real button with aria-haspopup="dialog" and a live aria-expanded; its accessible name (label alone, or label: chipText) always contains the text the eye sees once a selection engages, so the state is not masked by the category name. title carries the bare category, which is the tooltip a long chip needs.
- The trigger renders no caret: disclosure is announced by aria-expanded, which is why that attribute is not optional decoration. Do not style the chip so that the disclosure state is only visual.
- The pill group is a role="group" named by label. Every pill is a toggle button with aria-pressed; the all-pill is part of the same group, so its pressed state ("everything is shown") is stated in the same vocabulary as the picks.
- The hint line is plain text under the group — no role. If the facet's semantics (multi-select, clears others) are load-bearing, say them in a hint or in the group's context so a screen-reader user hears them.
- The Rust layer has no focus management and no outside-click close: the host opens it (writing open), focuses the first pill, closes it on Escape or a click outside, and returns focus to the chip.
Related components
- PillToggleGroup — the multi-select this popup wraps.
- FilterBar — the strip these chips sit in.
- FilterTrigger — the structured-condition alternative, for filters that are not a known option set.
- FilterPanel — the condition rows behind the trigger, when one facet is not enough.
- SearchTrigger — the keyword affordance that shares the header with these chips.