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

<mth-file-upload>

@methane-ui/ui~7.9 KB brotli (cold + Lit)~2.0 KB marginal

Form-associated file upload control with advisory MIME/size checks and safe image/SVG <img> previews.

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

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/file-upload"></script>
<mth-file-upload max-file-size="0" max-files="0"></mth-file-upload>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
valuevaluestring""Comma-separated list of selected file names.
namenamestring""Form field name.
labellabelstring""Accessible field label.
acceptacceptstring""Advisory comma-separated MIME types or extensions (e.g. .png,image/*).
multiplemultiplebooleanfalseAllows selecting multiple files.
maxFileSizemax-file-sizenumber0Advisory maximum file size in bytes (0 disables limit).
maxFilesmax-filesnumber0Advisory maximum number of files (0 disables limit).
disableddisabledbooleanfalseDisables interaction.
readonlyreadonlybooleanfalsePrevents adding or removing files.
requiredrequiredbooleanfalseRequires at least one file.

Events

EventDetail TypeDescription
mth-change{ files: File[]; value: string }Fired when selected files change.
mth-reject{ rejected: Array<{ file: File; reason: string }> }Fired when one or more files fail advisory checks.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
EnterbothBrowse button is focusedOpens native file chooser dialog
SpacebothRemove file button is focusedRemoves the corresponding file from the upload list

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