Skip to content
Ginga UI
Ginga UI
日本語

Getting started

  • Overview
  • Quick start
  • Theme generation
  • Custom rendering
  • All components

Forms

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

Display

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

Typography

  • Heading
  • Paragraph

Navigation

  • Anchor

Layout

  • Box

Resources

  • Changelog
  • GitHub (opens in a new tab)

Logo: Twemoji (opens in a new tab) (CC-BY 4.0)

ComboBox

A text input that filters a dropdown list of options as you type.

View in Storybook (opens in a new tab)

Installation

import { ComboBox } from "@ginga-ui/core";

Basic usage

Place ComboBoxItem elements inside. Typing filters the options.

combo-box.tsx
import { ComboBox, ComboBoxItem } from "@ginga-ui/core";
import { Check, ChevronDown } from "lucide-react";

export function BasicExample() {
  return (
    <ComboBox
      label="Prefecture"
      placeholder="Type to filter"
      icon={<ChevronDown />}
      checkIcon={<Check />}
    >
      {PREFECTURES.map((p) => (
        <ComboBoxItem key={p.id} id={p.id}>
          {p.name}
        </ComboBoxItem>
      ))}
    </ComboBox>
  );
}

Validation

Use description for help text and errorMessage for the message shown when the value is invalid.

Choose the prefecture for delivery
combo-box.tsx
import { ComboBox, ComboBoxItem } from "@ginga-ui/core";
import { ChevronDown } from "lucide-react";

export function ValidationExample() {
  return (
    <ComboBox
      label="Prefecture"
      description="Choose the prefecture for delivery"
      errorMessage="Choose a prefecture"
      required
      icon={<ChevronDown />}
    >
      {PREFECTURES.map((p) => (
        <ComboBoxItem key={p.id} id={p.id}>
          {p.name}
        </ComboBoxItem>
      ))}
    </ComboBox>
  );
}

Disabled

Pass disabled to disable the whole combo box.

combo-box.tsx
import { ComboBox, ComboBoxItem } from "@ginga-ui/core";
import { ChevronDown } from "lucide-react";

export function DisabledExample() {
  return (
    <ComboBox
      label="Prefecture"
      disabled
      defaultSelectedKey="osaka"
      icon={<ChevronDown />}
    >
      {PREFECTURES.map((p) => (
        <ComboBoxItem key={p.id} id={p.id}>
          {p.name}
        </ComboBoxItem>
      ))}
    </ComboBox>
  );
}

Props

ComboBox

NameTypeDefaultDescription
labelstring-Label shown above the combo box.
placeholderstring-Placeholder text of the input.
descriptionReactNode-Help text shown below the combo box.
errorMessageReactNode | ((validation: ValidationResult) => ReactNode)-Error message shown when the value is invalid.
disabledbooleanfalseDisables the combo box.
requiredbooleanfalseRequires a value.
readOnlybooleanfalseMakes the combo box read-only.
invalidbooleanfalseShows the combo box as invalid.
childrenReactNode-ComboBoxItem elements.
iconReactNode-Icon shown in the button that opens the list. A chevron is drawn when omitted.
checkIconReactNode-Icon shown next to the selected item.

Also accepts the props of React Aria's ComboBox (opens in a new tab).

ComboBoxItem

NameTypeDefaultDescription
disabledbooleanfalseDisables the item.
textValuestringchildren (string only)Text used for filtering and screen readers. Required when children is not a string.

Also accepts the props of React Aria's ListBoxItem (opens in a new tab).