nessra uinessra ui

An autocomplete input with a dropdown list of suggestions.

Loading...
"use client"

import {

Installation

pnpmnpmyarnbun
pnpm dlx shadcn@latest add https://nessra-ui.vercel.app/r/combobox.json

Usage

import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxList,
} from "@/components/ui/combobox"
const items = ["Next.js", "SvelteKit", "Nuxt.js", "Remix"] as const
 
<Combobox items={items}>
  <ComboboxInput placeholder="Select..." />
  <ComboboxContent>
    <ComboboxEmpty>No results.</ComboboxEmpty>
    <ComboboxList>
      {(item) => (
        <ComboboxItem key={item} value={item}>
          {item}
        </ComboboxItem>
      )}
    </ComboboxList>
  </ComboboxContent>
</Combobox>

Examples

With Clear Button

Use showClear to display a clear button when a value is selected.

Loading...
"use client"

import {

With Objects

Pass an array of objects as items. Use the object's properties to render custom content.

Loading...
"use client"

import * as React from "react"

Multiple Selection

Use multiple for multi-select with chips display.

Loading...
"use client"

import * as React from "react"

API Reference

Components

ComponentDescription
ComboboxRoot component wrapping all combobox parts
ComboboxInputText input with optional trigger and clear
ComboboxTriggerButton to toggle the dropdown
ComboboxValueDisplays the selected value
ComboboxContentDropdown container with positioning
ComboboxListRenders filtered items via render prop
ComboboxItemIndividual selectable option
ComboboxGroupGroups related items together
ComboboxLabelLabel for a group of items
ComboboxEmptyFallback content when no items match
ComboboxSeparatorVisual separator between items
ComboboxChipsContainer for multi-select chips
ComboboxChipIndividual chip for selected values
ComboboxChipsInputText input used within chips container

Combobox

PropTypeDefaultDescription
itemsT[]-Array of items to filter
valueT | T[]-Controlled selected value(s)
defaultValueT | T[]-Default selected value(s)
onValueChange(value: T) => void-Callback when value changes
multiplebooleanfalseEnable multiple selection
disabledbooleanfalseDisable the combobox
openboolean-Controlled open state
onOpenChange(open: boolean) => void-Callback when open changes

ComboboxInput

PropTypeDefaultDescription
placeholderstring-Input placeholder text
showTriggerbooleantrueShow dropdown trigger icon
showClearbooleanfalseShow clear button
disabledbooleanfalseDisable the input

ComboboxContent

PropTypeDefaultDescription
side"top" | "bottom" | "left" | "right""bottom"Preferred side
sideOffsetnumber6Distance from anchor
align"start" | "center" | "end""start"Alignment to anchor
alignOffsetnumber0Offset from alignment
anchorReact.RefObject-Custom anchor element

ComboboxItem

PropTypeDefaultDescription
valueT-The value of the item (required)
disabledbooleanfalseDisable the item

ComboboxChip

PropTypeDefaultDescription
showRemovebooleantrueShow remove button

useComboboxAnchor

Hook that returns a ref for custom anchor positioning with ComboboxChips.

const anchor = useComboboxAnchor()
 
<ComboboxChips ref={anchor}>...</ComboboxChips>
<ComboboxContent anchor={anchor}>...</ComboboxContent>