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

<mth-number-input>

@methane-ui/ui~10.1 KB brotli (cold + Lit)~3.2 KB marginal

Form-associated numeric spinbutton with precision-safe steppers, ArrowUp/ArrowDown keyboard control, min/max constraint validation, and Intl formatting.

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-number-input> (@methane-ui/ui)
Ready · interact with <mth-number-input>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/number-input"></script>
<mth-number-input step="1"></mth-number-input>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
valuevaluestring""Canonical string representation of the current number.
namenamestring""Form submission field name.
labellabelstring""Accessible label rendered inside shadow root.
hinthintstring""Helper text displayed below control.
errorerrorstring""Explicit validation error message.
placeholderplaceholderstring""Placeholder displayed when empty.
minminnumber | undefined—Minimum permitted numeric value.
maxmaxnumber | undefined—Maximum permitted numeric value.
stepstepnumber1Step increment for stepper buttons and Arrow keys.
localelocalestring""BCP-47 locale used by FormattingUtils for accessible aria-valuetext.
disableddisabledbooleanfalseDisables input and stepper buttons.
requiredrequiredbooleanfalseMarks control required.
readonlyreadonlybooleanfalsePrevents edits and disables steppers.

Events

EventDetail TypeDescription
mth-input{ value: string; valueAsNumber: number }Fired synchronously when numeric value updates.
mth-change{ value: string; valueAsNumber: number }Fired when edited or stepped value commits.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
ArrowUpbothspinbutton focused and not disabled/readonlyincrements value by step
ArrowDownbothspinbutton focused and not disabled/readonlydecrements value by step
Homebothspinbutton focused and min definedsets value to min
Endbothspinbutton focused and max definedsets value to max

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 4 APG keyboard transitions across LTR/RTL.mth-number-input.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(dirty), :state(touched), :state(user-invalid), :state(disabled), :state(required), :state(readonly).Conformance suite
i18nRoutes 7 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test