A searchable select, for one value or several. Shares the field styles of Input and Select.
import { Combobox } from "@kivu-ui/react"On this page
import { Combobox } from "@kivu-ui/react";value: Rwanda
import { useState } from "react";
import { Combobox } from "@kivu-ui/react";
const countries = ["Burundi", "DR Congo", "Kenya", "Rwanda", "Tanzania", "Uganda"];
export default function Demo() {
const [country, setCountry] = useState<string | null>("Rwanda");
return (
<div className="grid w-full max-w-xs gap-3">
<Combobox label="Country" labelPosition="outside" options={countries} value={country} onValueChange={setCountry} clearable />
<p className="font-mono text-xs text-fg-muted">value: {String(country)}</p>
</div>
);
}Options can have a description or be disabled.
import { Combobox } from "@kivu-ui/react";
const tags = [
{ value: "design", label: "Design" },
{ value: "eng", label: "Engineering" },
{ value: "growth", label: "Growth", description: "Marketing and sales" },
{ value: "ops", label: "Operations" },
{ value: "legal", label: "Legal", disabled: true },
];
export default function Demo() {
return (
<div className="w-full max-w-xs">
<Combobox multiple label="Teams" labelPosition="outside" placeholder="All teams" options={tags} defaultValue={["design", "eng"]} maxDisplayed={2} />
</div>
);
}| Prop | Type | Default | Description |
|---|---|---|---|
options | (string | { value, label, description?, icon?, disabled? })[] | - | Required. The choices. |
multiple | boolean | false | Allow several values (value becomes string[]). |
value / defaultValue | string | null | string[] | - | Selected value(s). |
onValueChange | (value) => void | - | Called when the selection changes. |
maxDisplayed | number | - | Multiple: labels listed before “+N”. |
searchable | boolean | true | Show the search box. |
searchPlaceholder | string | - | Placeholder for the search box. |
emptyText | ReactNode | - | Shown when nothing matches. |
filter | (option, query) => boolean | - | Custom matching. |
manualFilter / onSearchChange | boolean / (query) => void | - | Search on the server instead. |
loading | boolean | false | Show a loading row. |
clearable | boolean | false | Show a × button that clears the value. |
placeholder | ReactNode | - | Shown when nothing is selected. |
disabled | boolean | false | Disable the field. |
name | string | - | Adds hidden input(s) so the value posts with a native form. |
open / onOpenChange | boolean / (open) => void | - | Control the panel. |
panelClassName | string | - | Class for the floating panel. |
label | ReactNode | - | Field label, wired to the control with htmlFor. |
labelPosition | "inside" | "outside" | "inside" | Small label inside the box, or a regular label above it. |
description | ReactNode | - | Helper text; linked via aria-describedby. |
error | ReactNode | boolean | - | Error message (or true for just a red border). Sets aria-invalid. |
wrapperClassName | string | - | Class for the outer wrapper. className goes to the control itself. |
Every component also accepts className and forwards its ref. Root CSS class: .kivu-combobox