Select
Select chooses one or more values from a bounded option set.
@duskmoon-dev/components/select 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
Features
Documents default values, value props, and change callbacks for form integration.
Surfaces status, size, disabled, and option data patterns where the component supports them.
Select is most often configured through `allowClear`, `defaultValue`, `disabled`, `loading`.
Renders options, placeholder, size, status, loading, and disabled classes
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Basic usage
Import the component stylesheet and Select from its package subpath, then render it with the core props.
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
/>);
} Renders options, placeholder, size, status, loading, and disabled classes
test-backedSelect scenario from the component test coverage: renders options, placeholder, size, status, loading, and disabled classes.
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
/>);
} Supports uncontrolled selection and onChange payload
test-backedSelect scenario from the component test coverage: supports uncontrolled selection and onchange payload.
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
/>);
} Supports allowClear for single values
test-backedSelect scenario from the component test coverage: supports allowclear for single values.
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
/>);
} Supports multiple mode toggling
test-backedSelect scenario from the component test coverage: supports multiple mode toggling.
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
/>);
} Supports showSearch and filterOption
test-backedSelect scenario from the component test coverage: supports showsearch and filteroption.
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
/>);
} Supports tags mode custom values
test-backedSelect scenario from the component test coverage: supports tags mode custom values.
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
/>);
} Supports Select.Option and Select.OptGroup children
test-backedSelect scenario from the component test coverage: supports select.option and select.optgroup children.
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
/>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<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`, `defaultValue`, `disabled`, `loading` for common usage.
packages/components/src/components/select/Select.types.ts
Scenarios: packages/components/src/components/select/Select.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
allowClear | boolean | No | allowClear configures Select. |
children | ReactNode | No | children configures Select. |
defaultValue | SelectChangeValue | No | defaultValue configures Select. |
disabled | boolean | No | disabled configures Select. |
loading | boolean | No | loading configures Select. |
mode | SelectMode | No | mode configures Select. |
onChange | ( | No | onChange configures Select. |
value | SelectChangeValue, | Yes | value configures Select. |
option | SelectOptionType | SelectOptionType[], | No | option configures Select. |
options | SelectOptionInput[] | No | options configures Select. |
placeholder | ReactNode | No | placeholder configures Select. |
showSearch | boolean | No | showSearch configures Select. |
size | SelectSize | No | size configures Select. |
status | SelectStatus | No | status configures Select. |
value | SelectChangeValue | No | value configures Select. |
| Prop | Type | Required | Description |
|---|---|---|---|
label | ReactNode | No | label configures Select. |
value | SelectValue | Yes | value configures Select. |
disabled | boolean | No | disabled configures Select. |
className | string | No | className configures Select. |
| Prop | Type | Required | Description |
|---|---|---|---|
label | ReactNode | No | label configures Select. |
options | SelectOptionType[] | Yes | options configures Select. |
className | string | No | className configures Select. |
| Prop | Type | Required | Description |
|---|---|---|---|
children | ReactNode | No | children configures Select. |
disabled | boolean | No | disabled configures Select. |
value | SelectValue | Yes | value configures Select. |
| Prop | Type | Required | Description |
|---|---|---|---|
children | ReactNode | No | children configures Select. |
label | ReactNode | No | label configures Select. |
string | number "multiple" | "tags" "sm" | "md" | "lg" "error" | "success" SelectOptionType | SelectOptGroupType SelectValue | SelectValue[] | undefined ForwardRefExoticComponent< SelectProps & RefAttributes<HTMLDivElement> > & { Option: ForwardRefExoticComponent< SelectOptionProps & RefAttributes<HTMLDivElement> >