FilterChip
A filter as one pill, “Status is 2xx”: property, operator and value, each opening a menu.
function Basic() {
const [status, setStatus] = useState(["2xx"]);
const [op, setOp] = useState("is");
return (
<div className="flex items-center gap-8">
<FilterChip
property="Status"
propertyIcon={icons.chart}
operator={op}
operators={["is", "is not"]}
onOperatorChange={setOp}
value={status.length > 1 ? `${status.length} classes` : (status[0] ?? "any")}
multiple
values={[
{ value: "2xx", label: "2xx" },
{ value: "4xx", label: "4xx" },
{ value: "5xx", label: "5xx" },
]}
selected={status}
onSelectedChange={setStatus}
onRemove={() => setStatus([])}
/>
<Button variant="ghost" size="sm" leadingIcon={icons.add}>
Add filter
</Button>
</div>
);
}import { FilterChip } from "@logicplanes/kaeso-ui";Props
defaultValuesOpenbooleanOpen the value menu when the chip appears: a filter just added asks for its value at once.
freeText((text: string) => ReactNode)Lets what someone types in the search field be the value, for a filter no list can hold, such as text an error message contains: the label of the item that takes it. Enter takes it too.
groupsCommandListGroup[]Choices as ready-made searchable list groups, in place of
values: rows with marks and details and headings with logos, such asuseModelGroupsoruseProviderGroupsbuild.multiplebooleanSeveral values may be chosen.
onOperatorChange((operator: string) => void)Called with the chosen comparison.
onRemove(() => void)Called when the filter is removed.
onSelectedChange((selected: string[]) => void)Called with the chosen values.
onValuesOpenChange((open: boolean) => void)Called when the value menu opens or closes, so a filter just added can go away when it closes without a value.
operatorstring"is", "is not", "is any of"
operatorsstring[]The comparisons people can choose, such as “is” and “is not”.
propertyReactNode"Status"
propertyIconIconSvgElementThe icon of the property the filter applies to.
searchablebooleanGives the value menu a search field however few choices it has.
selectedstring[] = []The chosen values.
valueReactNodeThe value, as shown: "2xx", or "2 models".
valuesFilterChipChoice[]Choices for the value menu: past 8 it gets a search field, past 50 it opens a fast searchable list grouped by each choice's
group, such as models by provider.width"md" | "sm" | "lg"How wide the searchable list opens:
smfor providers,lgfor models with their details.