DataTableFacetedFilter() — ui Function Reference
Architecture documentation for the DataTableFacetedFilter() function in data-table-faceted-filter.tsx from the ui codebase.
Entity Profile
Dependency Diagram
graph TD 048cc097_ca48_88f5_82a8_d210fe801c02["DataTableFacetedFilter()"] 6ef7e23d_8854_babe_35fb_fc0ef77c5cfd["data-table-faceted-filter.tsx"] 048cc097_ca48_88f5_82a8_d210fe801c02 -->|defined in| 6ef7e23d_8854_babe_35fb_fc0ef77c5cfd style 048cc097_ca48_88f5_82a8_d210fe801c02 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
deprecated/www/app/(app)/examples/tasks/components/data-table-faceted-filter.tsx lines 34–147
export function DataTableFacetedFilter<TData, TValue>({
column,
title,
options,
}: DataTableFacetedFilterProps<TData, TValue>) {
const facets = column?.getFacetedUniqueValues()
const selectedValues = new Set(column?.getFilterValue() as string[])
return (
<Popover>
<PopoverTrigger asChild>
<Button variant="outline" size="sm" className="h-8 border-dashed">
<PlusCircle />
{title}
{selectedValues?.size > 0 && (
<>
<Separator orientation="vertical" className="mx-2 h-4" />
<Badge
variant="secondary"
className="rounded-sm px-1 font-normal lg:hidden"
>
{selectedValues.size}
</Badge>
<div className="hidden space-x-1 lg:flex">
{selectedValues.size > 2 ? (
<Badge
variant="secondary"
className="rounded-sm px-1 font-normal"
>
{selectedValues.size} selected
</Badge>
) : (
options
.filter((option) => selectedValues.has(option.value))
.map((option) => (
<Badge
variant="secondary"
key={option.value}
className="rounded-sm px-1 font-normal"
>
{option.label}
</Badge>
))
)}
</div>
</>
)}
</Button>
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0" align="start">
<Command>
<CommandInput placeholder={title} />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup>
{options.map((option) => {
const isSelected = selectedValues.has(option.value)
return (
<CommandItem
key={option.value}
onSelect={() => {
if (isSelected) {
selectedValues.delete(option.value)
} else {
selectedValues.add(option.value)
}
const filterValues = Array.from(selectedValues)
column?.setFilterValue(
filterValues.length ? filterValues : undefined
)
}}
>
<div
className={cn(
"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
isSelected
? "bg-primary text-primary-foreground"
: "opacity-50 [&_svg]:invisible"
)}
>
<Check />
Domain
Subdomains
Source
Frequently Asked Questions
What does DataTableFacetedFilter() do?
DataTableFacetedFilter() is a function in the ui codebase, defined in deprecated/www/app/(app)/examples/tasks/components/data-table-faceted-filter.tsx.
Where is DataTableFacetedFilter() defined?
DataTableFacetedFilter() is defined in deprecated/www/app/(app)/examples/tasks/components/data-table-faceted-filter.tsx at line 34.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free