FilterChip
A filter as one pill, “Status is 2xx”: property, operator and value, each opening a menu.
Status
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.
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.
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.
selectedstring[] = []The chosen values.
valueReactNodeThe value, as shown: "2xx", or "2 models".
valuesFilterChipChoice[]Choices for the value menu.