Filter Dropdown

A flexible dropdown filter component with support for multi-select and single-select modes.

Installation

pnpm dlx shadcn@latest add https://sase-ui.vercel.app/r/filter-dropdown.json

Usage

import { FilterDropdown } from "@/components/ui/filter-dropdown";
const [selectedValues, setSelectedValues] = React.useState<string[]>([])
 
const options = [
  { value: "option1", label: "Option 1", color: "bg-blue-500" },
  { value: "option2", label: "Option 2", color: "bg-green-500" },
]
 
<FilterDropdown
  label="Filter"
  options={options}
  selectedValues={selectedValues}
  onSelectionChange={setSelectedValues}
  mode="multi"
/>

Examples

Multi-Select

Single-Select

API Reference

FilterDropdown

PropTypeDefaultDescription
labelstring-The label displayed on the trigger button
optionsFilterOption[]-Array of filter options with value, label, and optional color
mode"multi" | "single""multi"Whether to use checkboxes (multi-select) or radio (single-select)
selectedValuesstring[][]Array of selected values (for multi-select mode)
selectedValuestring-Single selected value (for single-select mode)
onSelectionChange(values: string[]) => void-Callback when selection changes in multi-select mode
onValueChange(value: string) => void-Callback when selection changes in single-select mode
showColorDotsbooleantrueWhether to show color indicators
align"start" | "center" | "end""start"Dropdown content alignment
classNamestring-Custom class name for the trigger button

FilterOption

PropertyTypeDescription
valuestringThe unique value for the option
labelstringThe display text for the option
colorstringOptional Tailwind color class for the color dot (e.g., "bg-blue-500")