Prepared Docs

Prepared Docs

⌘K

    Loading navigation…

User

  1. Blocks
  2. Filters
  3. Accessibility

Filters

Accessibility

Overview

SortControl and Filter compose @prepared911/ui-core Menu, IconButton, and ButtonGroup. Those primitives own focus trap, arrow navigation, Escape dismissal, and focus return. This page covers what you must wire when using the Filters package APIs.

What the package handles

  • Multiple sort menu: MenuItemRadio inside MenuGroup with menuitemradio and aria-checked. Unselected rows are named by the criterion label. The selected row's accessible name is {criterion}, {direction} so assistive tech hears ascending vs descending without a nested control. Re-activating the checked row clears sort (criterionId: "") via useSortState.toggleCriterion.
  • Group-by menu: toggleable MenuItemCheckbox rows (menuitemcheckbox + aria-checked) with bare trailing checkmarks and optional decorative leading icons (aria-hidden). Single-select is enforced by SortControl / useSortState.toggleGroup — re-activating the checked row clears grouping (null). There is no explicit None option.
  • Direction trailing paint: morphing ascending/descending Icon on the selected non-fixedDirection criterion only. The slot is aria-hidden and must not introduce a nested button. Primary-button isolation keeps pointer toggles off the menuitemradio selection path until the gesture is confirmed (pointerup on the trailing region, or click without pointerdown for AT). pointercancel and drag-off do not change direction. Keyboard: ArrowLeft/ArrowRight on the selected radio toggles direction; that shortcut is also in description. Enter/Space still select or clear the criterion.
  • Simple sort toggle: IconButton with morphing ascending/descending icons, top tooltip of "Ascending" / "Descending", a stable localized aria-label (Sort {criterion}), and aria-pressed (true = ascending, false = descending).
  • ButtonGroup when grouping is set: default localized aria-label ("Sort and group"); override via the aria-label prop.
  • Menu keyboard: Tab to trigger, Enter/Space to open, arrows within menu, Escape to close (Menu contract).

What you must provide

  • Meaningful SortCriterion.label / GroupCriterion.label strings (localized at the call site when they are product copy).
  • Stable criteria / grouping configs so selection state and announcements stay consistent across re-renders.
  • If you override label / groupLabel / aria-label, keep them short and unique in the toolbar.

Keyboard behavior

  • Tab / Shift+Tab: reach sort and group icon buttons (and sibling toolbar controls).
  • Enter / Space: open the focused menu or activate the Simple toggle. On an already-selected sort criterion, Enter/Space clears sort (criterionId: ""), matching pointer activation on the row. On a checked group row, Enter/Space clears grouping.
  • Arrow keys: move among menuitemradio / menuitemcheckbox options while a menu is open. On the selected sort criterion, ArrowLeft/ArrowRight toggle direction without changing the criterion.
  • Escape: close the open menu and return focus to its trigger.

Semantics and roles

ControlRole / state
Sort / group triggersbutton named via IconButton title
Sort criterion optionsmenuitemradio + aria-checked; selected name includes direction
Group optionsmenuitemcheckbox + aria-checked (single-select via state)
Direction trailing (selected row)decorative aria-hidden paint; pointer isolation + ArrowLeft/ArrowRight
Simple direction togglebutton + aria-pressed (true ascending, false descending); stable name
Paired sort + groupgroup with accessible name

Screen reader notes

  • Do not put meaningful text only in leading icons — labels carry the name.
  • Trailing direction paint appears only on the selected criterion when it has no fixedDirection. It is aria-hidden; the selected radio's name includes the current direction, and description exposes ArrowLeft/ArrowRight. Direction is changed by pointer on that region or those arrow keys.
  • Clear grouping by re-activating the checked group row; ungrouped state is groupValue === null with all group checkboxes unchecked.
  • Clear Multiple sort by re-activating the checked criterion row; cleared state is criterionId: "" with all criterion radios unchecked.

Previous

Filters / API and Development

Next

Forms / Usage

On this page

Overview
What the package handles
What you must provide
Keyboard behavior
Semantics and roles
Screen reader notes