Skip to Content
NarakUI

Combobox

A popover with a searchable list, for picking one value or several.

Single selection

Compose Combobox.Root, a trigger, and Combobox.Content holding a Combobox.Command. Combobox.Input filters the rows of Combobox.List as you type, and Combobox.Empty shows when nothing matches. Mark the chosen row with a check in end and close the popover in onSelect.

Inside a form, use fullSizeAndButtonWithChevronToTheRight with w-full for a field-sized trigger, and fullWidth on the content so the list matches the trigger's width.

Answer engine

Multiple selection

Combobox.ItemCheckbox adds a checkbox to the row and keeps the popover open while you toggle. Hovering a row shows an only button; handle it with onOnlyClick to select that row alone, or pass showOnlyButton={false} to hide it.

A controlled Combobox.Input with onClear and clearLabel shows a clear button once there is a query. Put footer actions after the list behind a Combobox.Separator alwaysRender, so the divider stays while the list is filtered.

Groups

Combobox.Group takes a heading. Search hides a group once none of its rows match. Add the group name to each row's keywords so searching for the group finds its rows.

Trigger variants

buttonWithChevron renders a compact button with a chevron that flips while the list is open; pass mode="ghost" for an inline switcher in a header. Short lists can skip the input; pass shouldFilter={false} to Combobox.Command when there is nothing to filter. With asChild, any button opens the list, which suits actions such as adding a person.

Installation

pnpm dlx shadcn@latest add @narakui/combobox

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/combobox.json.

Usage

import { Combobox } from '@/components/ui/combobox';

<Combobox.Root open={open} onOpenChange={setOpen}>
  <Combobox.Trigger buttonWithChevron>{selectedLabel}</Combobox.Trigger>
  <Combobox.Content align="start">
    <Combobox.Command>
      <Combobox.Input placeholder="Search" autoFocus />
      <Combobox.List>
        <Combobox.Empty>No results found</Combobox.Empty>
        <Combobox.Group>
          <Combobox.Item value="chatgpt" onSelect={() => setOpen(false)}>
            ChatGPT
          </Combobox.Item>
        </Combobox.Group>
      </Combobox.List>
    </Combobox.Command>
  </Combobox.Content>
</Combobox.Root>

Search matches each row's value and keywords. When results come from the server, pass shouldFilter={false} to Combobox.Command, control the input with value and onValueChange, and render only the rows you get back. While they load, set loading on Combobox.Input to swap the search icon for a spinner, or render Combobox.Loading inside the list.

Combobox.Root is non-modal by default. Inside a drawer or a modal dialog it switches to modal automatically, so a long list can still scroll.

Combobox.Item with href renders a link row; Enter and click both navigate.

Combobox.Root Properties

PropTypeDefaultDescription
openboolean—Controlled open state of the popover
defaultOpenbooleanfalseInitial open state when uncontrolled
onOpenChange(open: boolean) => void—Called when the open state changes
modalbooleanfalseTraps focus and blocks the page behind the list. Always true inside a drawer or a modal dialog

Combobox.Trigger Properties

PropTypeDefaultDescription
asChildbooleanfalseMerges the trigger behavior into its child element, such as a Button
buttonWithChevronbooleanfalseRenders a Button with a chevron that flips while the list is open
fullSizeAndButtonWithChevronToTheRightbooleanfalseRenders a field-style Button with a truncated label on the left and the chevron on the right
iconStartIconValue—Button variants only. Icon name, descriptor, or node before the label
customIconEndIconValue—Button variants only. Replaces the chevron
hideChevronbooleanfalseButton variants only. Hides the chevron
size'micro' | 'small' | 'regular' | 'large'—Button variants only. buttonWithChevron defaults to small, the full-size variant to regular
modeButtonMode'secondary'Button variants only. Button style, such as ghost or dashed
loading{ isLoading: boolean }—Button variants only. The full-size variant shows a spinner in place of the chevron and is disabled
disabledbooleanfalseWhether the trigger is disabled
childrenClassNamestring—Full-size variant only. Classes for the label wrapper
contentClassNamestring—Button variants only. Classes for the Button's inner content

Combobox.Content Properties

PropTypeDefaultDescription
sizenumber249Minimum width of the popover in pixels
fullWidthbooleanfalseUses the trigger's width as the minimum width instead of size
align'start' | 'center' | 'end''center'Alignment of the popover relative to the trigger
side'top' | 'right' | 'bottom' | 'left''bottom'Preferred side of the trigger to render against
sideOffsetnumber10Distance in pixels from the trigger
alignOffsetnumber0Offset in pixels along the alignment axis
withRadixPortalbooleantrueRenders the popover in a portal. Set to false to render it in place
portalPropsPopoverPortalProps—Props for the portal, such as container
animateClosebooleantrueFades the popover out on close. Turn off when picking an option shifts the layout underneath

Combobox.Command Properties

PropTypeDefaultDescription
shouldFilterbooleantrueFilters and sorts rows by the input's query. Set to false when you filter the rows yourself
filter(value: string, search: string, keywords?: string[]) => number—Custom ranking. Return 0 to hide a row, higher numbers to rank it first
loopbooleantrueArrow keys wrap from the last row to the first
valuestring—Controlled value of the highlighted row
onValueChange(value: string) => void—Called when the highlighted row changes
labelstring—Accessible label for the command menu

Combobox.Input Properties

PropTypeDefaultDescription
placeholderstring—Placeholder text
valuestring—Controlled query
onValueChange(search: string) => void—Called when the query changes
loadingbooleanfalseShows a spinner in place of the search icon
onClear() => void—Shows a clear button while value is not empty. Requires clearLabel
clearLabelstring—Accessible label for the clear button. Required with onClear
classNameWrapperstring—Classes for the row that holds the icon and the input

Combobox.List Properties

PropTypeDefaultDescription
heightnumber | string300Maximum height before the list scrolls. Numbers are pixels; strings are any CSS length

Combobox.Item Properties

PropTypeDefaultDescription
valuestring—Unique value used for search and highlighting. Defaults to the row's text
keywordsstring[]—Extra terms that match the row in search
onSelect(value: string) => void—Called when the row is clicked or chosen with Enter
disabledbooleanfalseWhether the row is disabled
startIconValue—Icon name, descriptor, or node before the label
endIconValue—Icon name, descriptor, or node at the end of the row, such as a check for the chosen row
hrefstring—Renders the row as a link. Enter and click both navigate
prefetchbooleantrueWith href. Forwarded to Next.js Link
onNavigate() => void—With href. Called as the row starts navigating in this tab
disableTooltipbooleanfalseTurns off the tooltip that shows a truncated label in full
tooltipSide'top' | 'right' | 'bottom' | 'left''right'Side of the truncated-label tooltip
childrenClassNamestring—Classes for the label wrapper

Combobox.ItemCheckbox Properties

PropTypeDefaultDescription
checked (Required)boolean—Whether the row is checked
onSelect(value: string) => void—Called when the row is toggled
showOnlyButtonbooleantrueShows an only button on hover
onOnlyClick() => void—Called when the only button is clicked
checkboxDisabledReasonstring—Locks the checkbox and explains why in a tooltip. The row stays interactive
valuestring—Unique value used for search and highlighting
keywordsstring[]—Extra terms that match the row in search
disabledbooleanfalseWhether the row is disabled
startIconValue—Icon name, descriptor, or node between the checkbox and the label
endIconValue—Icon name, descriptor, or node after the label
disableTooltipbooleanfalseRenders the label without truncation, for labels that own their own layout

Combobox.Group and Combobox.Separator Properties

PropTypeDefaultDescription
headingReactNode—Group only. Heading shown above the group's rows
forceMountbooleanfalseGroup only. Keeps the group rendered when search matches none of its rows
alwaysRenderbooleanfalseSeparator only. Keeps the separator while there is a query. Without it, separators hide during search

Other Parts

PartTypeDescription
Combobox.EmptyComponentPropsWithoutRef<typeof Command.Empty>Shown when search matches no row
Combobox.LoadingComponentPropsWithoutRef<typeof Command.Loading>Loading row for async results. Takes label and progress
Combobox.LabelComponentPropsWithoutRef<'span'> & { size?: 'small' | 'medium' }Standalone heading outside a group. size defaults to small
Combobox.StandaloneButtonComponentPropsWithoutRef<'button'> & { start?: IconValue; end?: IconValue }Button styled like a row, for actions below the list
Combobox.StandaloneLinkLinkProps & { start?: IconValue; end?: IconValue }Link styled like a row, for navigation below the list