Skip to content

Select

The Select component provides a dropdown for choosing a single value from a list of options. It supports both controlled and uncontrolled modes, clearable selections, async loading, search filtering, grouped options, and the usual form-field affordances (label, caption, error/warning).

Variations

Suffix

The Select component can be customized with a suffix element that appears on the right side of the input.

Enable client-side search filtering to help users find options quickly in large or structured lists.

Async loading

Options can be loaded asynchronously by passing a function that returns a Promise.

Disabled states

Both the entire select and individual options can be disabled.

Open callback

The onOpen callback is triggered when the dropdown menu opens. This is useful for lazy loading data, logging analytics, or triggering side effects when users interact with the select.

Complex option labels

Options can have ReactNode labels for rich content display.

Custom option renderer

Customize how individual options are rendered using the optionRenderer prop. This allows advanced layouts or UI elements for each option.

Grouped options and separators

Installation

import { Select } from "@harnessio/ui/components";
//...
return (
<Select
options={[
{ label: "One", value: "one" },
{ label: "Two", value: "two" },
{ label: "Three", value: "three" },
{ label: "Four", value: "four", disabled: true },
]}
defaultValue="three"
onChange={(value) => console.log(value)}
/>
)