Filters
Data and metricsMITComposable filter builder with text, select, and number filter types.
bun add @otfdashkit/ui
Preview
FiltersData and metrics
Code
@otfdashkit/uiimport React from 'react'
import { Filters } from '@otfdashkit/ui'
import type { FilterDef, FilterValue } from '@otfdashkit/ui'
const filterDefs: FilterDef[] = [
{ key: 'status', label: 'Status', type: 'select', options: [{ label: 'Active', value: 'active' }, { label: 'Inactive', value: 'inactive' }] },
{ key: 'name', label: 'Name', type: 'text' },
{ key: 'amount', label: 'Amount', type: 'number' },
]
function FiltersDemo() {
const [filters, setFilters] = React.useState<FilterValue[]>([{ key: 'status', operator: 'equals', value: 'active' }])
return <Filters filters={filterDefs} value={filters} onChange={setFilters} />
}
export function Example() {
return (
<FiltersDemo />
)
}
Free with the SDK. This block ships in @otfdashkit/ui under the MIT license.
Kit for this component
Marketplace Kit$99
Add search and filter controls to a list of results.
Props
Props declared in the Filters source. Inherited HTML attributes are not listed.
| Prop | Type | Default | Description |
|---|---|---|---|
| filtersrequired | FilterDef[] | ||
| onChangerequired | (v: FilterValue[]) => void | ||
| valuerequired | FilterValue[] | ||
| className | string |