Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-select>

@methane-ui/ui~13.4 KB brotli (cold + Lit)~5.0 KB marginal

Form-associated select control with progressive customizable appearance: base-select detection and popover listbox fallback.

When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.

Live Interactive Preview

Interactive StageLive Custom Element · <mth-select> (@methane-ui/ui)
Astro SSR (DSD)Next.js 15 RSCNuxt 3 NitroSvelteKit 2Angular 19
Ready · interact with <mth-select>, or toggle Theme, Direction (LTR/RTL), or props above.

Live Variants & States Showcase

default + placeholderNode.js 22Deno 2Bun 1.2
clearable + selectedAstroNext.jsNuxt
error & disabledUS EastLocked Plan

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/select"></script>
<mth-select placement="bottom-start">Example</mth-select>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
namenamestring""Form field name submitted via FormData.
valuevaluestring""Selected option value (comma-separated when multiple).
defaultValuedefault-valuestring""Initial value used on form reset.
labellabelstring""Visible label text for the select.
hinthintstring""Supplementary helper text below the control.
errorerrorstring""Validation error message.
placeholderplaceholderstring""Placeholder shown when no option is selected.
openopenbooleanfalseWhether the fallback options popup is currently open.
multiplemultiplebooleanfalseAllows selecting multiple options.
disableddisabledbooleanfalseDisables user interaction and form submission.
requiredrequiredbooleanfalseMarks selection as required for constraint validation.
readonlyreadonlybooleanfalsePrevents changing the selection while keeping it focusable.
clearableclearablebooleanfalseRenders a clear button when a selection is present.
placementplacementstring"bottom-start"Preferred popup placement relative to the trigger.
forceFallbackforce-fallbackbooleanfalseForces the popover + positioned shadow listbox path even when base-select is supported.
options—ReadonlyArray<{ readonly id?: string; readonly value: string; readonly label: string; readonly disabled?: boolean; readonly group?: string }> | nullnullProgrammatic array of options.

Events

EventDetail TypeDescription
mth-change{ value: string; selectedValues: ReadonlyArray<string> }Fired when the selected value(s) change.
mth-openvoidCancelable event fired before opening the popup.
mth-after-openvoidFired after the popup opens.
mth-close{ reason: string }Cancelable event fired before closing the popup.
mth-after-close{ reason: string }Fired after the popup closes.
mth-clearvoidFired when the selection is cleared.
mth-invalid{ validity: ValidityState }Fired when constraint validation fails.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
Enterbothclosedopens listbox popup and highlights selected or first enabled option
Spacebothclosedopens listbox popup and highlights selected or first enabled option
ArrowDownbothclosedopens listbox popup and moves active highlight to first enabled option
ArrowDownbothopenmoves active option to next enabled option
ArrowUpbothopenmoves active option to previous enabled option
Homebothopenmoves active option to first enabled option
Endbothopenmoves active option to last enabled option
Enterbothopenselects active option and closes popup in single mode
Escapebothopencloses popup and restores focus to trigger

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 9 APG keyboard transitions across LTR/RTL.mth-select.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(open), :state(dirty), :state(touched), :state(user-invalid), :state(disabled), :state(readonly), :state(required), :state(invalid).Conformance suite
i18nRoutes 6 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test