DocsComponentsForms
Combobox
React example follows below.
ts
import { Combobox } from "@grassroot/ui-react"; const services = [ { value: "ledger-api", label: "ledger-api" }, { value: "ledger-worker", label: "ledger-worker" }, { value: "scheduler", label: "scheduler" }, { value: "billing-api", label: "billing-api" }, { value: "auth-gateway", label: "auth-gateway" }, { value: "search-index", label: "search-index" },]; const [value, setValue] = React.useState("ledger-api"); <Combobox label="Service" options={services} value={value} onValueChange={setValue} />ts
<script setup lang="ts">import { ref } from "vue";import { Combobox } from "@grassroot/ui-vue"; const services = [ { value: "ledger-api", label: "ledger-api" }, { value: "ledger-worker", label: "ledger-worker" }, { value: "scheduler", label: "scheduler" }, { value: "billing-api", label: "billing-api" }, { value: "auth-gateway", label: "auth-gateway" }, { value: "search-index", label: "search-index" },]; const value = ref("ledger-api");</script> <template> <Combobox v-model="value" label="Service" :options="services" /></template>ts
import { Component, signal } from "@angular/core";import { GrassrootCombobox } from "@grassroot/ui-angular"; @Component({ selector: "app-example", standalone: true, imports: [GrassrootCombobox], template: ` <grassroot-combobox label="Service" [options]="services" [value]="value()" (valueChange)="value.set($event)" /> `,})export class ExampleComponent { readonly services = [ { value: "ledger-api", label: "ledger-api" }, { value: "ledger-worker", label: "ledger-worker" }, { value: "scheduler", label: "scheduler" }, { value: "billing-api", label: "billing-api" }, { value: "auth-gateway", label: "auth-gateway" }, { value: "search-index", label: "search-index" }, ]; readonly value = signal("ledger-api");}ts
<script lang="ts"> import { Combobox } from "@grassroot/ui-svelte"; const services = [ { value: "ledger-api", label: "ledger-api" }, { value: "ledger-worker", label: "ledger-worker" }, { value: "scheduler", label: "scheduler" }, { value: "billing-api", label: "billing-api" }, { value: "auth-gateway", label: "auth-gateway" }, { value: "search-index", label: "search-index" }, ]; let value = $state("ledger-api");</script> <Combobox label="Service" options={services} value={value} onValueChange={(next) => (value = next)}/>ts
import { createSignal } from "solid-js";import { Combobox } from "@grassroot/ui-solid"; const services = [ { value: "ledger-api", label: "ledger-api" }, { value: "ledger-worker", label: "ledger-worker" }, { value: "scheduler", label: "scheduler" }, { value: "billing-api", label: "billing-api" }, { value: "auth-gateway", label: "auth-gateway" }, { value: "search-index", label: "search-index" },]; export function Example() { const [value, setValue] = createSignal("ledger-api"); return ( <> <Combobox label="Service" options={services} value={value()} onValueChange={setValue} /> </> );}Installation
bash
pnpm dlx grassroot add ui/comboboxbash
npx grassroot@latest add ui/comboboxbash
yarn dlx grassroot add ui/comboboxbash
bunx grassroot add ui/comboboxAPI Reference
| Prop | Type | Default |
|---|---|---|
optionsrequired | ComboboxOption[] | — |
value | string | undefined | — |
defaultValue | string | undefined | — |
onValueChange | ((value: string) => void) | undefined | — |
label | string | undefined | — |
"aria-label"Accessible name for trigger when no visible label is rendered. | string | undefined | — |
"aria-labelledby"ID of external element labelling the trigger. | string | undefined | — |
placeholder | string | undefined | — |
searchPlaceholderPlaceholder inside filter input. | string | undefined | "Search…" |
emptyTextShown when filter matches nothing. | string | undefined | "No results" |
defaultOpenRender initially open — handy for layout/stories. | boolean | undefined | false |
className | string | undefined | — |
id | string | undefined | — |