← All Components
<mth-file-upload>
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
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>import '@methane-ui/ui/file-upload';
import '@methane-ui/react';
export function Example() {
return <mth-file-upload max-file-size="0" max-files="0"></mth-file-upload>;
}<script setup lang="ts">
import '@methane-ui/ui/file-upload';
</script>
<template>
<mth-file-upload max-file-size="0" max-files="0"></mth-file-upload>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/file-upload';
import { MthFileUploadDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthFileUploadDirective],
template: `<mth-file-upload max-file-size="0" max-files="0"></mth-file-upload>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/file-upload';
import MthFileUpload from '@methane-ui/svelte/MthFileUpload.svelte';
</script>
<MthFileUpload max-file-size="0" max-files="0"></MthFileUpload>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
value | value | string | "" | Comma-separated list of selected file names. |
name | name | string | "" | Form field name. |
label | label | string | "" | Accessible field label. |
accept | accept | string | "" | Advisory comma-separated MIME types or extensions (e.g. .png,image/*). |
multiple | multiple | boolean | false | Allows selecting multiple files. |
maxFileSize | max-file-size | number | 0 | Advisory maximum file size in bytes (0 disables limit). |
maxFiles | max-files | number | 0 | Advisory maximum number of files (0 disables limit). |
disabled | disabled | boolean | false | Disables interaction. |
readonly | readonly | boolean | false | Prevents adding or removing files. |
required | required | boolean | false | Requires at least one file. |
Events
| Event | Detail Type | Description |
|---|---|---|
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
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter | both | Browse button is focused | Opens native file chooser dialog |
| Space | both | Remove file button is focused | Removes the corresponding file from the upload list |
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 2 APG keyboard transitions across LTR/RTL. | mth-file-upload.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(disabled), :state(readonly), :state(dirty), :state(touched), :state(invalid), :state(dragover). | Conformance suite |
| i18n | Routes 5 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |