# Filter bar

A controlled search and multi-filter surface with native popovers, removable filter chips, a clear action, and live result context.

Access: pro. Category: Blocks. Kind: composite.

## When to use

- Use it when a page needs a controlled search and multi-filter surface with native popovers, removable filter chips, a clear action, and live result context.
- Choose it inside an authenticated product surface when the host application owns routing, persistence, and service calls.

## Alternatives

- Choose empty-state instead when empty collections, search results and errors with a clear next action is the actual interface need, rather than filter bar.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Filter bar

```sh
npx shadcn@latest add @tidal-pro/filter-bar
```

Stylesheets: `components/ui/tidal.css`, `components/ui/filter-bar.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/filter-bar.css";
import{TidalFilterBar}from"./components/ui/filter-bar";
export default(p:Parameters<typeof TidalFilterBar>[0])=><div className="tidal-scope"><TidalFilterBar {...p}/></div>;
```

## Structured props

- `TidalFilterBar.accessibleLabel: string`: Required accessible label value accepted by this exported component.
- `TidalFilterBar.groups: ReadonlyArray<TidalFilterGroup>`: Required groups value accepted by this exported component.
- `TidalFilterBar.onFilterChange: (group: TidalFilterGroup, option: TidalFilterOption, selected: boolean, event: ChangeEvent<HTMLInputElement> | ReactMouseEvent<HTMLButtonElement>) => void`: Callback invoked when the filter change interaction is proposed.
- `TidalFilterBar.search: TidalFilterSearchControl`: Required search value accepted by this exported component.
- `TidalFilterBar.values: Readonly<Record<string, ReadonlyArray<string> | undefined>>`: Required values value accepted by this exported component.
- `TidalFilterBar.clearAction?: TidalFilterClearAction | undefined`: Optional clear action value accepted by this exported component.
- `TidalFilterBar.labels?: Partial<TidalFilterBarLabels> | undefined`: Optional labels value accepted by this exported component.
- `TidalFilterBar.resultSummary?: ReactNode`: Optional result summary value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/filter-bar.tsx) | [Manifest](https://tidalui.com/examples/filter-bar.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useId, useMemo, useRef, useState, type CSSProperties } from "react";

import { TidalFilterBar, type TidalFilterGroup } from "./components/ui/filter-bar";

import "./components/ui/filter-bar.css";



const tidalExampleStyles = ".tidal-scope .filter-bar-demo,\n.tidal-scope .filter-bar-demo * {\n  box-sizing: border-box;\n}\n\n.tidal-scope .filter-bar-demo {\n  container: filter-bar-demo / inline-size;\n  display: grid;\n  width: min(100%, 1080px);\n  min-width: 0;\n  gap: 18px;\n  margin-inline: auto;\n  padding: clamp(16px, 4vw, 42px);\n  color: var(--t-ink);\n}\n\n.tidal-scope .filter-bar-demo-heading {\n  display: grid;\n  min-width: 0;\n  gap: 7px;\n}\n\n.tidal-scope .filter-bar-demo-heading :is(h2, p),\n.tidal-scope .filter-bar-demo footer {\n  margin: 0;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .filter-bar-demo-heading h2 {\n  font-size: clamp(28px, 5vw, 44px);\n  font-weight: 570;\n  letter-spacing: -0.05em;\n  line-height: 1;\n}\n\n.tidal-scope .filter-bar-demo-heading p,\n.tidal-scope .filter-bar-demo footer {\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n}\n\n.tidal-scope .filter-bar-demo-results {\n  min-width: 0;\n}\n\n.tidal-scope .filter-bar-demo-results ul {\n  display: grid;\n  grid-template-columns: repeat(2, minmax(0, 1fr));\n  min-width: 0;\n  gap: 8px;\n  margin: 0;\n  padding: 0;\n  list-style: none;\n}\n\n.tidal-scope .filter-bar-demo-results li {\n  min-width: 0;\n  animation: filter-demo-result-in 360ms var(--t-ease-out) both;\n  animation-delay: calc(min(var(--filter-result-index), 7) * 45ms);\n}\n\n.tidal-scope .filter-bar-demo-results article {\n  display: grid;\n  grid-template-columns: minmax(0, 1fr) auto;\n  min-width: 0;\n  height: 100%;\n  gap: 18px;\n  padding: 18px;\n  border: 1px solid var(--t-border);\n  border-radius: 14px;\n  background: var(--t-surface);\n}\n\n.tidal-scope .filter-bar-demo-results article > div {\n  min-width: 0;\n}\n\n.tidal-scope .filter-bar-demo-results :is(h3, p, dl, dt, dd) {\n  margin: 0;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .filter-bar-demo-results h3 {\n  font-size: 15px;\n  font-weight: 650;\n  letter-spacing: -0.02em;\n}\n\n.tidal-scope .filter-bar-demo-results p {\n  margin-top: 6px;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n}\n\n.tidal-scope .filter-bar-demo-results dl {\n  display: grid;\n  grid-template-columns: repeat(2, minmax(58px, auto));\n  align-content: start;\n  gap: 8px;\n}\n\n.tidal-scope .filter-bar-demo-results dl > div {\n  min-width: 0;\n  padding-inline-start: 9px;\n  border-inline-start: 1px solid var(--t-border);\n}\n\n.tidal-scope .filter-bar-demo-results dt {\n  color: var(--t-muted);\n  font-size: 11px;\n  font-weight: 700;\n  letter-spacing: 0.08em;\n  text-transform: uppercase;\n}\n\n.tidal-scope .filter-bar-demo-results dd {\n  margin-top: 4px;\n  font-size: 11px;\n  font-weight: 620;\n}\n\n.tidal-scope .filter-bar-demo-empty {\n  display: grid;\n  min-width: 0;\n  justify-items: start;\n  gap: 8px;\n  padding: 28px;\n  border: 1px solid var(--t-border);\n  border-radius: 18px;\n  background: var(--t-subtle);\n}\n\n.tidal-scope .filter-bar-demo-empty button {\n  min-width: 44px;\n  min-height: 44px;\n  margin-top: 6px;\n  padding: 9px 13px;\n  border: 1px solid var(--t-ink);\n  border-radius: 10px;\n  background: var(--t-ink);\n  color: var(--t-surface);\n  font: inherit;\n  font-size: 11px;\n  font-weight: 650;\n  cursor: pointer;\n}\n\n.tidal-scope .filter-bar-demo-empty button:focus-visible {\n  outline: 2px solid var(--t-ink);\n  outline-offset: 3px;\n}\n\n@container filter-bar-demo (max-width: 620px) {\n  .tidal-scope .filter-bar-demo-results ul {\n    grid-template-columns: minmax(0, 1fr);\n  }\n\n  .tidal-scope .filter-bar-demo-results article {\n    grid-template-columns: minmax(0, 1fr);\n  }\n\n  .tidal-scope .filter-bar-demo-results dl {\n    grid-template-columns: repeat(2, minmax(0, 1fr));\n  }\n\n  .tidal-scope .filter-bar-demo-empty button {\n    font-size: 16px;\n  }\n}\n\n@keyframes filter-demo-result-in {\n  from {\n    opacity: 0;\n    transform: translateY(6px);\n  }\n  to {\n    opacity: 1;\n    transform: none;\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .filter-bar-demo-results li {\n    animation: none;\n  }\n}";

type ProjectStatus = "Active" | "Paused" | "Review";

type ProjectOwner = "Ava" | "Noah" | "Mila";

interface SampleProject {
  id: string;
  title: string;
  description: string;
  status: ProjectStatus;
  owner: ProjectOwner;
}

type IndexedResultStyle = CSSProperties & { "--filter-result-index": number };

const SAMPLE_PROJECTS: readonly SampleProject[] = [
  {
    id: "field-notes",
    title: "Field notes",
    description: "Organize research from the latest site visit.",
    status: "Active",
    owner: "Ava",
  },
  {
    id: "launch-brief",
    title: "Launch brief",
    description: "Resolve the final review comments before handoff.",
    status: "Review",
    owner: "Noah",
  },
  {
    id: "archive-plan",
    title: "Archive plan",
    description: "Map the folders that move into the shared archive.",
    status: "Paused",
    owner: "Mila",
  },
  {
    id: "support-guide",
    title: "Support guide",
    description: "Write a concise guide for common workspace questions.",
    status: "Active",
    owner: "Mila",
  },
  {
    id: "release-checklist",
    title: "Release checklist",
    description: "Confirm ownership for the remaining release checks.",
    status: "Review",
    owner: "Ava",
  },
  {
    id: "brand-library",
    title: "Brand library",
    description: "Sort approved marks and usage notes for the team.",
    status: "Active",
    owner: "Noah",
  },
  {
    id: "workspace-audit",
    title: "Workspace audit",
    description: "Review inactive boards and document their owners.",
    status: "Paused",
    owner: "Ava",
  },
  {
    id: "meeting-notes",
    title: "Meeting notes",
    description: "Prepare the decisions and follow-up list for review.",
    status: "Review",
    owner: "Mila",
  },
];

const FILTER_GROUPS: readonly TidalFilterGroup[] = [
  {
    id: "status",
    label: "Status",
    accessibleLabel: "Filter by project status",
    options: ["Active", "Paused", "Review"].map((status) => ({
      value: status.toLowerCase(),
      label: status,
      accessibleLabel: status,
      inputProps: { name: "status" },
    })),
  },
  {
    id: "owner",
    label: "Owner",
    accessibleLabel: "Filter by project owner",
    options: ["Ava", "Noah", "Mila"].map((owner) => ({
      value: owner.toLowerCase(),
      label: owner,
      accessibleLabel: owner,
      inputProps: { name: "owner" },
    })),
  },
];

export function FilterBarDemo() {
  const demoId = useId().replace(/:/g, "");
  const headingId = `${demoId}-work-queue`;
  const resultsId = `${demoId}-projects`;
  const searchRef = useRef<HTMLInputElement>(null);
  const [query, setQuery] = useState("");
  const [values, setValues] = useState<Record<string, readonly string[]>>({
    status: [],
    owner: [],
  });

  const visibleProjects = useMemo(() => {
    const normalizedQuery = query.trim().toLowerCase();
    return SAMPLE_PROJECTS.filter((project) => {
      const matchesQuery =
        !normalizedQuery ||
        `${project.title} ${project.description} ${project.owner} ${project.status}`
          .toLowerCase()
          .includes(normalizedQuery);
      const selectedStatuses = values.status ?? [];
      const selectedOwners = values.owner ?? [];
      const matchesStatus =
        !selectedStatuses.length ||
        selectedStatuses.includes(project.status.toLowerCase());
      const matchesOwner =
        !selectedOwners.length ||
        selectedOwners.includes(project.owner.toLowerCase());
      return matchesQuery && matchesStatus && matchesOwner;
    });
  }, [query, values]);

  const hasFilters =
    Boolean(query) || Object.values(values).some((selected) => selected.length);

  function clearFilters() {
    setQuery("");
    setValues({ status: [], owner: [] });
    searchRef.current?.focus({ preventScroll: true });
  }

  return (
    <section className="filter-bar-demo" aria-labelledby={headingId}>
      <header className="filter-bar-demo-heading">
        <h2 id={headingId}>Work queue</h2>
        <p>Find projects by title, status, or owner.</p>
      </header>

      <TidalFilterBar
        accessibleLabel="Project filters"
        search={{
          label: "Search projects",
          value: query,
          placeholder: "Search the queue",
          onValueChange: setQuery,
          inputProps: { autoComplete: "off" },
          inputRef: searchRef,
        }}
        groups={FILTER_GROUPS}
        values={values}
        onFilterChange={(group, option, selected) => {
          setValues((current) => {
            const groupValues = current[group.id] ?? [];
            return {
              ...current,
              [group.id]: selected
                ? groupValues.includes(option.value)
                  ? groupValues
                  : [...groupValues, option.value]
                : groupValues.filter((value) => value !== option.value),
            };
          });
        }}
        clearAction={{
          label: "Clear",
          accessibleLabel: "Clear search and filters",
          disabled: !hasFilters,
          onAction: clearFilters,
        }}
        resultSummary={`${visibleProjects.length} ${
          visibleProjects.length === 1 ? "project" : "projects"
        } shown`}
      />

      <div className="filter-bar-demo-results" id={resultsId}>
        {visibleProjects.length ? (
          <ul aria-label="Filtered projects">
            {visibleProjects.map((project, index) => (
              <li
                key={project.id}
                style={{ "--filter-result-index": index } as IndexedResultStyle}
              >
                <article>
                  <div>
                    <h3>{project.title}</h3>
                    <p>{project.description}</p>
                  </div>
                  <dl>
                    <div>
                      <dt>Status</dt>
                      <dd>{project.status}</dd>
                    </div>
                    <div>
                      <dt>Owner</dt>
                      <dd>{project.owner}</dd>
                    </div>
                  </dl>
                </article>
              </li>
            ))}
          </ul>
        ) : (
          <div className="filter-bar-demo-empty">
            <h3>No matching projects</h3>
            <p>Clear the current search and filters to see the full queue.</p>
            <button type="button" onClick={clearFilters}>
              Show all projects
            </button>
          </div>
        )}
      </div>

      <footer>Fictional project data changes only on this page.</footer>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <FilterBarDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation.","Escape dismisses the open overlay where the underlying primitive supports dismissal."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

accessibleLabel, controlled search, consumer-owned filter groups, values and onFilterChange are required; group IDs are unique and stable and option values are unique within each group. Search renders a labelled native controlled type=search input with compatible attributes/ref and caller-first prevented change composition; controlled type/value/defaultValue/placeholder are excluded. Each group owns its label, accessible label, options, optional disabled state, native trigger/popover/close attributes and refs. Trigger buttons invoke the HTML Popover API with light dismissal and Escape behavior; opening positions a width/height-bounded popover from the current trigger geometry after an unprevented consumer beforetoggle handler, then keeps it aligned on owner-window scroll/resize until close. Native controlled checkboxes expose compatible attributes/ref and caller-first prevented change composition. Selected recognized values render removable native button chips with attributes/refs and consumer-defined accessible labels. An accepted immediate or delayed removal moves focus to its stable group trigger only when the removed control/body still owns focus; declined changes and externally moved focus are preserved. Optional clearAction renders a native button with caller-first prevented click composition and returns focus to search only if accepted state disables/removes the focused action. Component-owned disabled states resolve to native disabled behavior and conflicting ARIA disabled props are excluded. Optional resultSummary is a polite status and nullish checks preserve numeric content. The component performs no filtering, request, navigation, analytics, network, storage or persistence work.
