FilterBar

FilterBar

HkFilterBar is the standard filter strip for list and table pages, in its two standardized shapes: inline is the bare row — one surface, an aligned field row in the default slot, and a trailing actions column carrying the active-filter count and the Reset verb; popover is the collapsed form — one trigger button (icon + label + count) anchoring the same fields plus an Apply/Reset footer. The bar owns the chrome, the count and the two verbs; the fields are yours.

  • Filters that are the page's main interaction (a dense ledger) go inline; filters that merely narrow a page go popover, the default posture — a filter band should not permanently occupy the page.
  • Two neighbours take the opposite stance: FilterTrigger puts the same panel behind a header icon button, and SearchTrigger does it for a keyword. Use this bar when the fields are always visible or one row deep; use the trigger when the page should show only a marked affordance.
  • The condition rows this bar's panel would hold inside a narrower surface are FilterPanel; a single facet's multi-select opening from a chip is FilterChip.

Import

tsx
1
import { HkFilterBar } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // FilterBar, FilterBarMode
use hikari_components::prelude::*; // FilterBarProps, rsx!, VNode, EventHandler, MouseEvent

The Rust form is FilterBar(FilterBarProps { … }); mode is FilterBarMode::{Inline, Popover}, label is an Option<String> whose None falls back to the localized "Filters", and the fields are the children slot. Inside rsx! everything may be omitted; the default mode is Inline and the footer defaults to on.

Inline: one row, a count and a Reset verb

The inline shape renders role="search" with aria-label from label, a .hk-filter-bar-fields cell holding your controls, and a .hk-filter-bar-actions column. The count chip (a sm, primary badge) renders only while something is active; the Reset button is ghost/small and disabled at zero rather than hidden — the affordance stays exactly where it was. Reset emits reset and does not change any state itself: your fields decide what clearing means.

The two fields above are inert stand-ins — this page is about the bar's chrome, and the Rust card is a static snapshot. They paint the frame the TSX card starts in: one region chosen (EU), an empty owner and the active counter at 1. Swap in the real field components for a live bar.

Popover: the collapsed shape and its footer

The collapsed form wraps a secondary/small button labelled by label (with the filter glyph and the count chip inside), opening a .hk-filter-bar-panel that holds the fields and, while showFooter stays on, an Apply/Reset footer. The Apply verb closes the panel and then emits apply — that order is deliberate (open = false, then emit("apply")), so a host that refetches on apply is already past the close; Reset inside the footer emits the same reset as the inline shape. Keep the footer off only when the fields commit live on their own.

The popover's own open state is Vue's (it starts closed and Vue's update:modelValue drives it); the Rust form takes open as a controlled prop with on_open_change out. A snapshot cannot open a popover, so the Rust example below passes open: true to render the open frame statically — that is the state, not an interaction.

The first Rust bar is the collapsed frame (aria-expanded="false", no panel in the DOM); the second is the open one — panel, fields and footer. The TSX card starts collapsed: press the trigger to see the same open frame, and Apply to close it. There is no way to write "open" as a TSX prop, because Vue owns that ref.

[D] On Vue, the trigger's count chip and the panel share the trigger's own popover; on Rust there is no popover runtime at all — the panel is absolutely positioned against the bar's own position: relative root via filter_popup_layer_style, so a placement on the Rust bar takes a PopoverPlacement and positions the layer inline, without measurement, flipping or viewport clamping. Vue's placement reaches the real popper. Same place on screen for a bottom-start panel, different machinery — anchoring inside a scrolling or clipping ancestor may differ.

Disabled, the count contract and the verb order

disabled reaches three places: the reset verb (always), the Apply verb in the footer, and the popover trigger. It never disables your fields — those are your controls, and the bar cannot know what "disabled" means for them. The count is a number you provide (activeCount); the bar does not inspect the fields, so a bar that shows 3 is telling you three conditions are live, and it is your job to keep that honest.

The count rule is shared across the whole filter family: FilterTrigger turns a non-zero count into a corner dot instead, FilterPanel counts non-empty condition values, and FilterChip counts a selection. Pick one counting rule per page so the marks agree.

At zero active filters the inline Reset is disabled (not gone), the count chip is not rendered at all, and the popover trigger carries disabled; the open Rust bar shows the same trigger state with the footer's two verbs disabled. class on the Rust bar is appended to the root; the Vue side takes a plain fallthrough class.

API

Vue

Props

NameTypeDefaultRequired
mode<code>String as PropType<"inline" | "popover"></code>"inline"—
activeCountNumber0—
labelStringundefined—
showFooterBooleantrue—
disabledBooleanfalse—
placementString as PropType<PopupPlacement>"bottom-start"—

Emits

EventPayload
apply—
reset—

Rust

Props — FilterBar

PropTypeDefaultDescription
modeFilterBarModeFilterBarMode::InlineWhich standardized shape renders (Vue default "inline").
active_countu320How many filters are currently active (drives the count badge).
labelOption<String>NoneAccessible name / trigger text (Vue default: the localized "Filters").
show_footerbooltruepopover mode: render the Apply/Reset footer.
disabledboolfalse—
placementPopoverPlacementPopoverPlacement::BottomStartLayer placement against the trigger (Vue default "bottom-start").
openboolfalsepopover mode: the panel's visibility (Vue: the local open ref).
on_open_changeOption<EventHandler<bool>>NoneFires with the desired open state (Vue: the local open writes).
on_applyOption<EventHandler<()>>NoneThe Apply verb in the footer (Vue: the apply emit).
on_resetOption<EventHandler<()>>NoneThe reset verb (inline actions column / popover footer; Vue: reset).
childrenElement(empty)The consumer's own field controls (Vue: the default slot).

Accessibility

  • The inline shape is a search landmark: role="search" named by label. Pass a label that says what is being filtered ("Ledger filters"), not a generic "Filters", so the landmark list is navigable.
  • The popover trigger is a real button labelled with label, and it carries aria-haspopup="dialog" and a live aria-expanded, so the disclosure state is always stated. In the Rust form the same attributes ride the button; there is no aria-controls on either side (the panel has no stable id) — give the panel a labelled heading if it needs one.
  • The count chip is text (2) inside the trigger or the actions column; it has no label of its own, so say "2 filters active" in the button's label if the digit alone is ambiguous.
  • The Reset verb is disabled at zero rather than hidden — a control that appears and disappears is harder to find than one that greys out. Keep that behaviour if you hand-roll the actions column.
  • The Apply/Reset footer belongs to the popover shape only; the inline shape has no footer, so a live-committing inline bar needs no extra verb.
  • Fields inside the bar are yours: label them (ariaLabel on the library inputs), and keep the DOM order of the fields the reading order you want.

Related components

  • FilterTrigger — the same panel behind a header icon button, with a corner dot instead of a count.
  • FilterPanel — the condition rows an inline bar can hold in its fields slot.
  • FilterChip — a single facet's chip trigger, for a facet strip beside the bar.
  • SearchTrigger — the keyword twin of the trigger, for pages that also search.
  • Table — the roster the bar narrows.