Actions
Filter
Toolbar filter trigger (muted label + value + chevron) and a dashed “Add filter” button.
react-aria-componentslucide-react
Preview
"use client";
import { AddFilterButton, FilterButton } from "@/components/ui/filter";
export default function Example() {
return (
<div className="flex flex-wrap items-center gap-2">
<FilterButton label="Owner" value="All owners" />
<FilterButton label="Stage" value="Qualified" />
<FilterButton label="Score" value="≥ 80" />
<AddFilterButton />
</div>
);
}Installation
Components are copied into your project — no runtime package.
Install the following dependencies:
terminalnpm install react-aria-components lucide-reactCreate a
filter.tsxfile and paste the following code into it.src/components/ui/filter.tsx"use client"; import { ChevronDown, Plus } from "lucide-react"; import type { ReactNode } from "react"; import { Button as AriaButton, type ButtonProps } from "react-aria-components"; import { cx } from "@/utils/cx"; export interface FilterButtonProps extends Omit<ButtonProps, "children" | "className" | "value"> { label: string; value: ReactNode; className?: string; } /** Toolbar filter: muted label + value + chevron. */ export function FilterButton({ label, value, className, ...props }: FilterButtonProps) { return ( <AriaButton {...props} className={cx( "group inline-flex h-9 cursor-default items-center gap-1.5 rounded-md bg-surface px-3 text-base shadow-button outline-none transition-colors", "data-hovered:bg-subtle data-pressed:bg-active data-focus-visible:shadow-focus aria-expanded:shadow-[inset_0_0_0_1px_var(--color-accent),var(--shadow-focus)]", className, )} > <span className="text-fg-muted">{label}</span> <span className="font-medium text-fg">{value}</span> <ChevronDown aria-hidden className="size-3.5 text-fg-muted transition-transform group-aria-expanded:rotate-180" /> </AriaButton> ); } /** Add style is a dashed ghost trigger. */ export function AddFilterButton({ className, children = "Add filter", ...props }: Omit<ButtonProps, "className" | "children"> & { className?: string; children?: ReactNode }) { return ( <AriaButton {...props} className={cx( "inline-flex h-9 cursor-default items-center gap-1.5 rounded-md border border-dashed border-line-strong px-3 text-base text-fg-secondary outline-none transition-colors", "data-hovered:border-fg-disabled data-hovered:bg-subtle data-hovered:text-fg data-focus-visible:shadow-focus", className, )} > <Plus aria-hidden className="size-3.5" /> {children} </AriaButton> ); }Add the theme tokens and the
cxhelper from Installation if you haven’t yet, then update the import paths to match your project setup.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | — | Muted label, e.g. “Owner”. |
| value | ReactNode | — | Current value. |