SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

FilterMenu

One filterable popover list for every "pick from many" trigger.

View code
tsx
<FilterMenu
	id="ref-picker"
	mode="navigate"
	tabs
	trigger={<><GitBranchIcon size={16} aria-hidden="true" /> main</>}
	groups={[
		{ label: "Branches", items: branches.map((branch) => ({
			value: branch.name,
			label: branch.name,
			href: `/acme/delta/tree/${branch.name}`,
			badge: branch.isDefault ? "default" : undefined,
			selected: branch.name === current,
		})) },
		{ label: "Tags", items: tags.map((tag) => ({ value: tag, label: tag, href: `/acme/delta/tree/${tag}` })) },
	]}
	filterAction="/acme/delta/branches"
	footer={<a href="/acme/delta/branches">View all branches</a>}
	labels={{
		title: "Switch branches/tags",
		filter: "Find a branch…",
		empty: "Nothing to show",
		more: "{count} more",
		save: "Save",
		tabs: "Ref type",
	}}
/>

Demo apps

Whole pages built only from @sdxc/ui, each for an invented product with its own palette and type. They open in a new tab.

Every demo, landings and docs sites alike, is listed in the demo gallery.

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
import { FilterMenu } from "@sdxc/ui/app";

Renders a trigger and its native popover: links in navigate mode, a form posted to action by its Save button in single and multiple. Mapping @sdxc/ui/app/filter-menu in the browser entry runs FilterMenuList: typing filters, arrows walk, and closing a changed picker posts.

Composition

The parts the component publishes, each a static property of the host.

  • FilterMenu
  • FilterMenu.PopoverRenders the popover alone, for a trigger the page already has, such as a property row's edit button targeting id.

Examples

Labels, several at once

View code
tsx
<FilterMenu
	id="issue-labels"
	mode="multiple"
	name="label"
	action="/acme/delta/issues/231/labels"
	trigger="Labels"
	groups={[{ label: "Labels", items: labels.map((label) => ({
		value: label.id,
		label: label.name,
		description: label.description,
		color: label.color,
		selected: issue.labels.includes(label.id),
	})) }]}
	labels={{
		title: "Apply labels to this issue",
		filter: "Filter labels",
		empty: "No labels match",
		more: "{count} more",
		save: "Save",
	}}
/>

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeRequiredDescription
triggerRemixNodeYesThe trigger's content, such as a branch icon and the current branch's name.

Also accepts everything in PopoverProps.

FilterMenu.Popover

PropTypeRequiredDescription
idstringYesThe popover's id, which the trigger, or any popovertarget, opens.
mode"navigate" | "single" | "multiple"YesWhether rows are links, radios or checkboxes.
groupsGroup[]YesEvery choice, sent whole to the island so filtering never waits on the server.
tabsbooleanNoDraws the groups as tabs (Branches | Tags) instead of stacked sections.
namestringNoThe field name radios and checkboxes post under; required for single and multiple.
actionstringNoWhere single and multiple post. Defaults to the current address.
targetstringNoThe named <Frame> the post loads into, so only that frame reloads.
filterActionstringNoA page that filters with ?q=, which the filter field submits to without script.
querystringNoThe filter already applied, as the filterAction page read it.
limitnumberNoHow many matches the list draws before one closing "more" row. @default 100
footerRemixNodeNoA closing link or action, such as "View all branches".
placementPopover.PlacementNoThe trigger's side the popover opens on above phone widths. @default "bottom-start"
labelsLabelsYesEvery string the menu shows, so it reads in any language.

Also accepts everything in Omit<TagProps<"div">, "id" | "children" | "popover">.

Types

NameValuesWhat it decides
Mode"navigate" | "single" | "multiple""navigate" makes every item a link (a branch picker); "single" and "multiple" make them radios or checkboxes named name, posted to action when the popover closes.
@sdxc/ui

Can’t find it? Contact us