← All Components
<mth-combobox>
Form-associated accessible combobox reconciling declarative <mth-option>/<mth-option-group>, .options JS arrays, and async DataSource<T> queries with same-root shadow ARIA and dual CSS Anchor / JS positioning.
When NOT to use: Do not use <mth-combobox> for 2–4 static choices without search; use <mth-radio-group> or native <select>.
Live Interactive Preview
Ready · interact with <mth-combobox>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/combobox"></script>
<mth-combobox filterable placement="bottom-start">Example</mth-combobox>import '@methane-ui/ui/combobox';
import '@methane-ui/react';
export function Example() {
return <mth-combobox filterable placement="bottom-start">Example</mth-combobox>;
}<script setup lang="ts">
import '@methane-ui/ui/combobox';
</script>
<template>
<mth-combobox filterable placement="bottom-start">Example</mth-combobox>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/combobox';
import { MthComboboxDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthComboboxDirective],
template: `<mth-combobox filterable placement="bottom-start">Example</mth-combobox>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/combobox';
import MthCombobox from '@methane-ui/svelte/MthCombobox.svelte';
</script>
<MthCombobox filterable placement="bottom-start">Example</MthCombobox>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
name | name | string | "" | Form field name submitted via ElementInternals. |
value | value | string | "" | Current selected value (comma-separated when multiple is true). |
defaultValue | default-value | string | "" | Initial value restored when the enclosing form resets. |
label | label | string | "" | Visible and accessible label for the combobox input. |
hint | hint | string | "" | Helper text describing expected input or options. |
error | error | string | "" | Explicit error message marking the combobox invalid. |
placeholder | placeholder | string | "" | Input placeholder text. |
open | open | boolean | false | Controls visibility of the floating options popup. |
multiple | multiple | boolean | false | Enables multi-value selection without dismissing on selection. |
disabled | disabled | boolean | false | Disables interaction and excludes from form submission. |
required | required | boolean | false | Marks combobox selection as required for constraint validation. |
readonly | readonly | boolean | false | Prevents typing or changing selection while remaining focusable. |
clearable | clearable | boolean | false | Shows a clear button when text or value is non-empty. |
filterable | filterable | boolean | true | Filters local options dynamically as the user types. |
placement | placement | string | "bottom-start" | Preferred popup placement relative to the combobox control. |
forceFallback | force-fallback | boolean | false | Forces JS fallback positioning instead of native CSS Anchor Positioning. |
options | — | ReadonlyArray<{ readonly id?: string; readonly value: string; readonly label: string; readonly disabled?: boolean; readonly group?: string }> | null | null | Imperative option array overriding declarative slotted children. |
dataSource | — | { query(request: { cursor?: string; filter?: string; signal: AbortSignal }): Promise<{ items: ReadonlyArray<{ readonly id?: string; readonly value: string; readonly label: string; readonly disabled?: boolean; readonly group?: string }>; total?: number; nextCursor?: string | null }> } | null | null | Async DataSource<T> queried on filter changes with stale-request abort protection. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-input | { value: string } | Fired as the user types in the combobox input. |
mth-change | { value: string; selectedValues: ReadonlyArray<string> } | Fired when selection changes. |
mth-open | void | Cancelable event fired before opening the popup. |
mth-after-open | void | Fired after the popup opens and positions. |
mth-close | { reason: string } | Cancelable event fired before closing the popup. |
mth-after-close | { reason: string } | Fired after the popup closes. |
mth-clear | void | Fired when the clear action resets query and selection. |
mth-invalid | { validity: ValidityState } | Fired when form constraint validation fails. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowDown | both | closed | opens popup and activates first enabled option |
| ArrowDown | both | open | moves active option highlight to next enabled option |
| ArrowUp | both | open | moves active option highlight to previous enabled option |
| Enter | both | open and not composing IME | selects active option and updates value |
| Escape | both | open | dismisses popup and restores focus |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 5 APG keyboard transitions across LTR/RTL. | mth-combobox.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(open), :state(dirty), :state(touched), :state(user-invalid), :state(disabled), :state(readonly), :state(required), :state(invalid), :state(loading), :state(empty), :state(error). | Conformance suite |
| i18n | Routes 6 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |