FilterTrigger
HkFilterTrigger is the header filter affordance: a ghost icon button on the chrome action ladder (ghost/32 on wide screens, ghost/28 narrow) that anchors a FilterPanel in a popover on desktop and a bottom sheet on mobile, and wears a green bottom-right dot while any condition carries a value. It is the collapsed sibling of FilterBar: same panel, same state, but the page shows only a marked button until someone asks.
- Reach for it when filters should not occupy a band of the page — the header action row, next to the search affordance. Reach for FilterBar when the fields are the page's main interaction.
- Its twin is SearchTrigger: the same chrome step, the same corner dot, the same one-panel interaction, one glyph apart. A page normally carries both, side by side in the header action row, with the filter before the search.
- Apply semantics are deliberate: desktop has no confirm button (edits commit live and the panel is dismissed by clicking out); mobile has exactly one confirm button that closes the sheet. There is no cancel, and clearing a condition means re-opening the panel and emptying its value.
Import
;
from "@celestia-island/hikari";
use *; // FilterTrigger, FilterFieldDef, FilterFieldKind, FilterCondition, FilterOperator, AddMenuState
use *; // FilterTriggerProps, rsx!, VNode, EventHandler
The Rust form is FilterTrigger(FilterTriggerProps { … }). It takes the panel's props (fields, model_value, disabled, label) plus its own (placement, narrow, open) and passes the panel's three controlled-state pairs straight through (add_menu_open / add_highlight / open_row and their handlers). Inside rsx! every prop may be omitted except the two panel inputs, which default to empty.
The active dot, the chrome ladder and the panel
The dot is on precisely when at least one condition carries a non-empty value — including a condition on a field the page no longer declares, so a stale state still reads as "this page is filtered". It is a mark, not a verb: it lives in the corner badge's dot form (success tone, bottom-right, 1px offset), aria-hidden, and intercepts nothing.
The button's step is the shared chrome ladder (ghost/32 wide, ghost/28 narrow — the same step as the search and settings buttons), so the header cluster reads as one row. That step, and nothing else, is what the Rust narrow prop changes on its own side: the mirror spends narrow on the chrome step and on the mobile confirm footer, which Vue derives from useBreakpoint().
1 filter(s) active
Both cards show the closed trigger with its dot lit. The TSX card opens a real popover on click; the Rust card renders only what its open prop says — the popover/panel is a state, not an interaction here.
One controlled open, two footprints
Vue keeps open in a local ref and hands the same boolean to its popover. The Rust form takes open as a prop and emits on_open_change, so a host wires one boolean to both the trigger and the layer; the panel's own controlled state rides along untouched (on_value_change is the state write, and it fires live, exactly as on desktop).
The open frame differs by form factor: on the narrow footprint the layer carries a footer with a single primary "Apply" button, and the Apply closes the sheet — edits are already committed. On the wide footprint there is no footer at all.
The two Rust triggers are the same panel opened on each footprint: the left one is wide (no footer), the right one is narrow (ghost/28 button plus the Apply footer) and is placed above its anchor so the open panel stays inside the frame. The TSX card starts closed: press the funnel to see the wide open frame. Only the Vue runtime knows when the footprint turns narrow, so the mobile footer appears there without a prop — that is the one shape the TSX card cannot be made to show on a desktop preview.
aboveChrome is a Vue-only prop (isNative() hosts forward it): it lifts the panel over the window caption band. The Rust layer is an absolutely positioned body positioned by filter_popup_layer_style against the trigger's own position: relative, so it has no caption-band awareness and takes no such prop.
Disabled, placement and what the host owns
disabled reaches the trigger button, the Apply footer button, and every control inside the panel (which is itself disabled). The trigger keeps its dot if a state is still active — a disabled filter button on a filtered page should still say the page is filtered.
placement is the anchor relation (bottom-end by default on both sides). The Rust layer is inline geometry: no measurement, no auto-flip, no viewport clamp, and no outside-click close — the host owns dismissal (click-outside, Escape, route change) and passes a Top* placement when the trigger sits in a bottom band. Vue gets all of that from its popover runtime.
A disabled trigger: the button carries disabled, the panel inside it is inert, and an active state still lights the dot — the Rust card shows exactly that (disabled, dot lit). The TSX card is disabled with nothing active yet. Press it in the TSX card and nothing opens; that is the whole of the disabled contract.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| fields | Array as PropType<HkFilterFieldDef[]> | — | ✓ |
| modelValue | Array as PropType<HkFilterState> | () => [] | — |
| disabled | Boolean | false | — |
| label | String | undefined | — |
| placement | String as PropType<PopupPlacement> | "bottom-end" | — |
| aboveChrome | Boolean | false | — |
Emits
| Event | Payload |
|---|---|
| update:modelValue | HkFilterState |
Rust
Props — FilterTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
| fields | Vec<FilterFieldDef> | [] | The page's declared fields (Vue: fields, required). |
| model_value | FilterState | Default::default() | The condition state — the panel edits it live (Vue: modelValue). |
| disabled | bool | false | — |
| label | Option<String> | None | Accessible name / sheet title (Vue default: the localized "Filters"). |
| placement | PopoverPlacement | PopoverPlacement::BottomEnd | Layer placement against the trigger (Vue default "bottom-end"). |
| narrow | bool | false | Vue's useBreakpoint().isMobile stand-in: the host passes platform::inner_width() < 768. |
| open | bool | false | — |
| add_menu_open | bool | false | The panel's add-condition chooser (Vue: the panel's own addMenuOpen). |
| add_highlight | i32 | -1 | The chooser's highlighted row (Vue: the panel's addHighlight). |
| open_row | Option<u32> | None | The panel row whose popup control is open (see FilterPanel). |
| on_open_change | Option<EventHandler<bool>> | None | Fires with the desired open state (Vue: the local open writes). |
| on_value_change | Option<EventHandler<FilterState>> | None | Fires with the next condition state (Vue: update:modelValue). |
| on_add_menu_change | Option<EventHandler<AddMenuState>> | None | Fires with the next chooser state (the panel's pass-through). |
| on_open_row_change | Option<EventHandler<Option<u32>>> | None | Fires with the panel row whose popup should open (the pass-through). |
Accessibility
- The trigger is a real button labelled by label ("Filters"), with aria-haspopup="dialog" and a live aria-expanded. Pass a name that says what it filters when the page has more than one filter surface.
- The active dot is aria-hidden decoration. Nothing in the accessibility tree says "filters are active" unless your page says it elsewhere — an active-count hint in the trigger's label, or the list's own "showing N of M" line.
- The header action row keeps a fixed order — create action, then the filter button, then the search affordance — so the two entry points never swap places between pages. That order belongs to the page chrome, not to this component.
- On desktop the panel is dismissed by clicking out and commits live; there is no confirm button to announce. On mobile the single Apply button is the closing verb. Do not add a cancel button — its absence is the design.
- The panel itself is a FilterPanel and carries that page's accessibility contract (labelled operator groups, pressed states, the chooser's menu pattern).
- The Rust layer has no focus management: the host must move focus into the panel when it opens and return it to the trigger when it closes, and must close it on Escape.
Related components
- SearchTrigger — the twin affordance: same chrome step, same dot, a keyword panel instead of conditions.
- FilterPanel — the condition rows this trigger shows.
- FilterBar — the always-visible strip, when filters deserve a row of their own.
- FilterChip — a single facet's chip trigger, for a facet strip beside the header actions.