Data Entryduskmoonimplemented14 demos

Select

Select chooses one or more values from a bounded option set.

Import@duskmoon-dev/components/select
12API sections
31documented props
12behavior scenarios
Key API
allowCleardefaultOpendefaultValuedisabledloadingmode

Usage

When to use

  • Use it inside forms, filters, settings, and any workflow that captures user input.
  • Prefer controlled props when the value must stay synchronized with application state.

Implementation notes

StylesheetImport @duskmoon-dev/components/styles.css once in the app or docs shell.
StateStart with default props for static examples, then switch to controlled props when state must be shared.
ThemeThe preview inherits the active DuskMoon data-theme value from the docs layout.

Features

Controlled and uncontrolled usage

Documents default values, value props, and change callbacks for form integration.

Validation state

Surfaces status, size, disabled, and option data patterns where the component supports them.

Primary API surface

Select is most often configured through `allowClear`, `defaultOpen`, `defaultValue`, `disabled`.

Covered behavior

Renders graphical caret and clear controls without changing accessible names

Feature Demos

Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.

Preview

Basic usage

authored

Import the component stylesheet and Select from its package subpath, then render it with the core props.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function Example() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview

Renders graphical caret and clear controls without changing accessible names

test-backed

Select scenario from the component test coverage: renders graphical caret and clear controls without changing accessible names.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function SelectRendersGraphicalCaretAndDemo() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview

Uses aria-labelledby as the trigger

test-backed

Select scenario from the component test coverage: uses aria-labelledby as the trigger.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function SelectUsesAriaLabelledbyAsDemo() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview

Renders options, placeholder, size, status, loading, and disabled classes

test-backed

Select scenario from the component test coverage: renders options, placeholder, size, status, loading, and disabled classes.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function SelectRendersOptionsPlaceholderSizeDemo() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview

Supports uncontrolled selection and onChange payload

test-backed

Select scenario from the component test coverage: supports uncontrolled selection and onchange payload.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function SelectSupportsUncontrolledSelectionAndDemo() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview

Supports allowClear for single values

test-backed

Select scenario from the component test coverage: supports allowclear for single values.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function SelectSupportsAllowClearForSingleDemo() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview

Supports multiple mode toggling

test-backed

Select scenario from the component test coverage: supports multiple mode toggling.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function SelectSupportsMultipleModeTogglingDemo() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview

Supports showSearch and filterOption

test-backed

Select scenario from the component test coverage: supports showsearch and filteroption.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function SelectSupportsShowSearchAndFilterOptionDemo() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview

Supports tags mode custom values

test-backed

Select scenario from the component test coverage: supports tags mode custom values.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function SelectSupportsTagsModeCustomDemo() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview

Supports Select.Option and Select.OptGroup children

test-backed

Select scenario from the component test coverage: supports select.option and select.optgroup children.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function SelectSupportsSelectOptionAndDemo() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview

Uses Popover API with popover=

test-backed

Select scenario from the component test coverage: uses popover api with popover=.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function SelectUsesPopoverAPIWithDemo() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview

Closes when clicking outside the select container

test-backed

Select scenario from the component test coverage: closes when clicking outside the select container.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function SelectClosesWhenClickingOutsideDemo() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview

Tracks native popover toggle event

test-backed

Select scenario from the component test coverage: tracks native popover toggle event.

Source
import "@duskmoon-dev/components/styles.css";
import { Select } from "@duskmoon-dev/components/select";

export function SelectTracksNativePopoverToggleDemo() {
  return (<Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>);
}
Preview
Sunshine Theme
Moonlight Theme

Theme aware

authored

Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.

Source
<div data-theme="sunshine">
  <Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>
</div>

<div data-theme="moonlight">
  <Select
  options={[
    { label: "React", value: "react" },
    { label: "Astro", value: "astro" },
    { label: "TypeScript", value: "typescript" }
  ]}
  defaultValue="react"
  placeholder="Select a stack"
  allowClear
/>
</div>

API

The API reference below lists every parsed exported type or interface for Select. Start with `allowClear`, `defaultOpen`, `defaultValue`, `disabled` for common usage.

Types: packages/components/src/components/select/Select.types.tsScenarios: packages/components/src/components/select/Select.test.tsx
SelectPropsinterface extends Omit< ComponentProps<"div">, "children" | "defaultValue" | "onChange" >
PropTypeRequiredDescription
allowClearbooleanNoallowClear configures Select.
childrenReactNodeNochildren configures Select.
defaultOpenbooleanNodefaultOpen configures Select.
defaultValueSelectChangeValueNodefaultValue configures Select.
disabledbooleanNodisabled configures Select.
loadingbooleanNoloading configures Select.
modeSelectModeNomode configures Select.
onChange(NoonChange configures Select.
valueSelectChangeValue,Yesvalue configures Select.
optionSelectOptionType | SelectOptionType[],Nooption configures Select.
onDropdownVisibleChange(open: boolean) => voidNoonDropdownVisibleChange configures Select.
onOpenChange(open: boolean) => voidNoonOpenChange configures Select.
openbooleanNoopen configures Select.
optionsSelectOptionInput[]Nooptions configures Select.
placeholderReactNodeNoplaceholder configures Select.
showSearchbooleanNoshowSearch configures Select.
sizeSelectSizeNosize configures Select.
statusSelectStatusNostatus configures Select.
valueSelectChangeValueNovalue configures Select.
SelectOptionTypeinterface
PropTypeRequiredDescription
labelReactNodeNolabel configures Select.
valueSelectValueYesvalue configures Select.
disabledbooleanNodisabled configures Select.
classNamestringNoclassName configures Select.
SelectOptGroupTypeinterface
PropTypeRequiredDescription
labelReactNodeNolabel configures Select.
optionsSelectOptionType[]Yesoptions configures Select.
classNamestringNoclassName configures Select.
SelectOptionPropsinterface extends Omit< ComponentProps<"div">, "children" >
PropTypeRequiredDescription
childrenReactNodeNochildren configures Select.
disabledbooleanNodisabled configures Select.
valueSelectValueYesvalue configures Select.
SelectOptGroupPropsinterface extends Omit< ComponentProps<"div">, "children" >
PropTypeRequiredDescription
childrenReactNodeNochildren configures Select.
labelReactNodeNolabel configures Select.
SelectValuetype
Type definition
string | number
SelectModetype
Type definition
"multiple" | "tags"
SelectSizetype
Type definition
"sm" | "md" | "lg"
SelectStatustype
Type definition
"error" | "success"
SelectOptionInputtype
Type definition
SelectOptionType | SelectOptGroupType
SelectChangeValuetype
Type definition
SelectValue | SelectValue[] | undefined
SelectComponenttype
Type definition
ForwardRefExoticComponent< SelectProps & RefAttributes<HTMLDivElement> > & { Option: ForwardRefExoticComponent< SelectOptionProps & RefAttributes<HTMLDivElement> >