AutoComplete
AutoComplete pairs text entry with suggested options for searchable pickers and command inputs.
@duskmoon-dev/components/auto-complete 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.
AutoComplete is most often configured through `allowClear`, `color`, `defaultOpen`, `defaultValue`.
Renders combobox, placeholder, classes, and options
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Colors
Match options
Async match
Allow clear
Colors and matching
AutoComplete supports the full semantic color palette: primary, secondary, tertiary, accent, neutral, base, info, success, warning, error.
import "@duskmoon-dev/components/styles.css";
import { AutoComplete } from "@duskmoon-dev/components/auto-complete";
const colors = [
"primary",
"secondary",
"tertiary",
"accent",
"neutral",
"base",
"info",
"success",
"warning",
"error"
] as const;
const options = [
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" },
{ value: "solid", label: "Solid" }
];
export function AutoCompleteColorsDemo() {
return (<div style={{ display: "grid", gap: 10 }}>
{colors.map((color) => (
<AutoComplete
key={color}
color={color}
placeholder={`${color} search`}
options={options}
/>
))}
</div>);
} Basic usage
Import the component stylesheet and AutoComplete from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { AutoComplete } from "@duskmoon-dev/components/auto-complete";
export function Example() {
return (<AutoComplete
color="primary"
allowClear
defaultOpen
defaultValue="re"
options={[
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" }
]}
/>);
} Renders combobox, placeholder, classes, and options
test-backedAutoComplete scenario from the component test coverage: renders combobox, placeholder, classes, and options.
import "@duskmoon-dev/components/styles.css";
import { AutoComplete } from "@duskmoon-dev/components/auto-complete";
export function AutoCompleteRendersComboboxPlaceholderClassesDemo() {
return (<AutoComplete
color="primary"
allowClear
defaultOpen
defaultValue="re"
options={[
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" }
]}
/>);
} Colors
Match options
Async match
Allow clear
Supports all color classes
test-backedAutoComplete scenario from the component test coverage: supports all color classes.
import "@duskmoon-dev/components/styles.css";
import { AutoComplete } from "@duskmoon-dev/components/auto-complete";
export function AutoCompleteSupportsAllColorClassesDemo() {
return (<AutoComplete
color="primary"
allowClear
defaultOpen
defaultValue="re"
options={[
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" }
]}
/>);
} Supports uncontrolled search and filtering
test-backedAutoComplete scenario from the component test coverage: supports uncontrolled search and filtering.
import "@duskmoon-dev/components/styles.css";
import { AutoComplete } from "@duskmoon-dev/components/auto-complete";
export function AutoCompleteSupportsUncontrolledSearchAndDemo() {
return (<AutoComplete
color="primary"
allowClear
defaultOpen
defaultValue="re"
options={[
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" }
]}
/>);
} Supports selecting an option
test-backedAutoComplete scenario from the component test coverage: supports selecting an option.
import "@duskmoon-dev/components/styles.css";
import { AutoComplete } from "@duskmoon-dev/components/auto-complete";
export function AutoCompleteSupportsSelectingAnOptionDemo() {
return (<AutoComplete
color="primary"
allowClear
defaultOpen
defaultValue="re"
options={[
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" }
]}
/>);
} Supports controlled value and open state
test-backedAutoComplete scenario from the component test coverage: supports controlled value and open state.
import "@duskmoon-dev/components/styles.css";
import { AutoComplete } from "@duskmoon-dev/components/auto-complete";
export function AutoCompleteSupportsControlledValueAndDemo() {
return (<AutoComplete
color="primary"
allowClear
defaultOpen
defaultValue="re"
options={[
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" }
]}
/>);
} Supports allowClear
test-backedAutoComplete scenario from the component test coverage: supports allowclear.
import "@duskmoon-dev/components/styles.css";
import { AutoComplete } from "@duskmoon-dev/components/auto-complete";
export function AutoCompleteSupportsAllowClearDemo() {
return (<AutoComplete
color="primary"
allowClear
defaultOpen
defaultValue="re"
options={[
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" }
]}
/>);
} Supports AutoComplete.Option children and notFoundContent
test-backedAutoComplete scenario from the component test coverage: supports autocomplete.option children and notfoundcontent.
import "@duskmoon-dev/components/styles.css";
import { AutoComplete } from "@duskmoon-dev/components/auto-complete";
export function AutoCompleteSupportsAutoCompleteOptionChildrenDemo() {
return (<AutoComplete
color="primary"
allowClear
defaultOpen
defaultValue="re"
options={[
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" }
]}
/>);
} Supports disabled state
test-backedAutoComplete scenario from the component test coverage: supports disabled state.
import "@duskmoon-dev/components/styles.css";
import { AutoComplete } from "@duskmoon-dev/components/auto-complete";
export function AutoCompleteSupportsDisabledStateDemo() {
return (<AutoComplete
color="primary"
allowClear
defaultOpen
defaultValue="re"
options={[
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" }
]}
/>);
} Includes component stylesheet rules
test-backedAutoComplete scenario from the component test coverage: includes component stylesheet rules.
import "@duskmoon-dev/components/styles.css";
import { AutoComplete } from "@duskmoon-dev/components/auto-complete";
export function AutoCompleteIncludesComponentStylesheetRulesDemo() {
return (<AutoComplete
color="primary"
allowClear
defaultOpen
defaultValue="re"
options={[
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" }
]}
/>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<AutoComplete
color="primary"
allowClear
defaultOpen
defaultValue="re"
options={[
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" }
]}
/>
</div>
<div data-theme="moonlight">
<AutoComplete
color="primary"
allowClear
defaultOpen
defaultValue="re"
options={[
{ value: "react", label: "React" },
{ value: "remix", label: "Remix" },
{ value: "astro", label: "Astro" }
]}
/>
</div> API
The API reference below lists every parsed exported type or interface for AutoComplete. Start with `allowClear`, `color`, `defaultOpen`, `defaultValue` for common usage.
packages/components/src/components/auto-complete/AutoComplete.types.ts
Scenarios: packages/components/src/components/auto-complete/AutoComplete.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
allowClear | boolean | No | allowClear configures AutoComplete. |
children | ReactNode | No | children configures AutoComplete. |
color | AutoCompleteColor | No | color configures AutoComplete. |
defaultOpen | boolean | No | defaultOpen configures AutoComplete. |
defaultValue | string | No | defaultValue configures AutoComplete. |
disabled | boolean | No | disabled configures AutoComplete. |
filterOption | AutoCompleteFilterOption | No | filterOption configures AutoComplete. |
notFoundContent | ReactNode | No | notFoundContent configures AutoComplete. |
onChange | (value: string, option?: AutoCompleteOptionType) => void | No | onChange configures AutoComplete. |
onSearch | (value: string) => void | No | onSearch configures AutoComplete. |
onSelect | (value: string, option: AutoCompleteOptionType) => void | No | onSelect configures AutoComplete. |
open | boolean | No | open configures AutoComplete. |
options | AutoCompleteOptionType[] | No | options configures AutoComplete. |
placeholder | string | No | placeholder configures AutoComplete. |
size | AutoCompleteSize | No | size configures AutoComplete. |
value | string | No | value configures AutoComplete. |
| Prop | Type | Required | Description |
|---|---|---|---|
value | string | Yes | value configures AutoComplete. |
label | ReactNode | No | label configures AutoComplete. |
disabled | boolean | No | disabled configures AutoComplete. |
className | string | No | className configures AutoComplete. |
| Prop | Type | Required | Description |
|---|---|---|---|
children | ReactNode | No | children configures AutoComplete. |
disabled | boolean | No | disabled configures AutoComplete. |
value | string | Yes | value configures AutoComplete. |
"sm" | "md" | "lg" | "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error" | boolean | ((inputValue: string, option: AutoCompleteOptionType) => boolean) ForwardRefExoticComponent< AutoCompleteProps & RefAttributes<HTMLDivElement> > & { Option: ForwardRefExoticComponent< AutoCompleteOptionProps & RefAttributes<HTMLDivElement> >