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)

Select

A select box for choosing an item from a dropdown list.

View in Storybook (opens in a new tab)

Installation

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

Basic usage

A simple select box example.

Favorite animal
select.tsx
import { Select, SelectItem } from "@ginga-ui/core";
import { Check, ChevronDown } from "lucide-react";

export function BasicExample() {
  return (
    <Select
      icon={<ChevronDown />}
      checkIcon={<Check />}
      defaultSelectedKey="cat"
      label="Favorite animal"
    >
      <SelectItem id="cat">Cat</SelectItem>
      <SelectItem id="dog">Dog</SelectItem>
      <SelectItem id="bird">Bird</SelectItem>
    </Select>
  );
}

Disabled options

A select box with some options disabled.

Choose a pet
select.tsx
import { Select, SelectItem } from "@ginga-ui/core";
import { Check, ChevronDown } from "lucide-react";

export function DisabledOptionsExample() {
  return (
    <Select
      icon={<ChevronDown />}
      checkIcon={<Check />}
      defaultSelectedKey="dog"
      label="Choose a pet"
    >
      <SelectItem id="dog">Dog</SelectItem>
      <SelectItem id="cat">Cat</SelectItem>
      <SelectItem id="hamster" disabled>
        Hamster (out of stock)
      </SelectItem>
      <SelectItem id="parrot">Parrot</SelectItem>
    </Select>
  );
}

Disabled

An example of disabling the entire select box.

Favorite animal
select.tsx
import { Select, SelectItem } from "@ginga-ui/core";
import { Check, ChevronDown } from "lucide-react";

export function DisabledExample() {
  return (
    <Select
      icon={<ChevronDown />}
      checkIcon={<Check />}
      disabled
      defaultSelectedKey="cat"
      label="Favorite animal"
    >
      <SelectItem id="cat">Cat</SelectItem>
      <SelectItem id="dog">Dog</SelectItem>
      <SelectItem id="bird">Bird</SelectItem>
    </Select>
  );
}

Controlled select

A select box whose state is controlled externally.

Skill level
select.tsx
import { Select, SelectItem } from "@ginga-ui/core";
import { Check, ChevronDown } from "lucide-react";

export function ControlledExample() {
  return (
    <Select
      icon={<ChevronDown />}
      checkIcon={<Check />}
      label="Skill level"
      defaultSelectedKey="beginner"
      onSelectionChange={(key) => console.log("Selected:", key)}
    >
      <SelectItem id="beginner">Beginner</SelectItem>
      <SelectItem id="intermediate">Intermediate</SelectItem>
      <SelectItem id="advanced">Advanced</SelectItem>
    </Select>
  );
}

Props

Select

NameTypeDefaultDescription
labelstring-Required. Label shown above the select.
childrenReactNode-SelectItem elements.
descriptionReactNode-Help text shown below the select.
errorMessageReactNode | ((validation: ValidationResult) => ReactNode)-Error message shown when the value is invalid.
disabledbooleanfalseDisables the select.
requiredbooleanfalseRequires a selection.
invalidbooleanfalseShows the select as invalid.
iconReactNode-Icon shown at the end of the button.
checkIconReactNode-Icon shown next to the selected item.

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

SelectItem

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

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