Combobox

An input field that combines a text input with a dropdown list of suggestions.

Installation

Import the component from the passport-ui package.

components/example.tsx
1
2
import { Combobox } from "passport-ui";
import { useState } from "react";

Usage

Basic example showing how to use the component.

components/example.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const frameworks = [
{ value: "next.js", label: "Next.js" },
{ value: "sveltekit", label: "SvelteKit" },
{ value: "nuxt.js", label: "Nuxt.js" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" },
];
function ComboboxExample() {
const [value, setValue] = useState<string>("");
return (
<div className="w-sm">
<Combobox
options={frameworks}
value={value}
onValueChange={setValue}
placeholder="Select framework..."
searchPlaceholder="Search frameworks..."
emptyText="No framework found."
/>
</div>
);
}

Additional resources

Documentation and examples are available in Storybook.