Skip to content

File Input ​

A modern file upload component with drag-and-drop support, file list management, constraint filtering, and full form integration. Shares the same visual theme system as ore-input.

Filename Display ​

List and gallery captions truncate the filename stem while retaining its final extension: quarterly.report.pdf becomes quarterly… followed by .pdf when space is limited. Multi-part suffixes preserve only the final segment (archive.tar.gz keeps .gz). Dotfiles such as .env, extensionless names, and names ending in a dot truncate as a single name. The complete filename remains in the caption's text and title, and in file-action accessible labels.

Variants ​

Six visual variants for different UI contexts and levels of emphasis.

Full width

Colors ​

Six semantic colors for different contexts and validation states.

Full width

Sizes ​

Three sizes for different contexts.

Full width

Rounded (Custom Border Radius) ​

Dropzones default to --radius (8px at a 16px root). Use the rounded attribute to select another theme radius, including rounded="xl" for the previous 12px shape.

Full width

Customization ​

Multiple Files ​

Enable multi-file selection with the multiple attribute. Use multiple only when your backend truly supports multiple files per field.

Full width

Accept Filter ​

Restrict accepted file types using MIME types or file extensions. The accepted types are shown in the dropzone hint automatically. Always pair with helper text to document accepted types so users know what is expected.

Full width

Set gallery to render selected files as a grid of thumbnails instead of the default single-column list: a better fit for photo uploads. Image files render an actual preview; other file types fall back to a generic file icon in the same grid cell. Object URLs are created lazily and revoked automatically when a file is removed or the component disconnects.

Full width

File Size & Count Limits ​

Use max-size (bytes) and max-files to enforce constraints. Files that don't meet the criteria are silently filtered out. The limits appear in the dropzone hint. Always validate these constraints on the server as well: client-side filtering alone is not sufficient.

Full width

With Helper Text ​

Provide context below the dropzone using the helper attribute. Always provide a label to clearly communicate what files are expected.

Full width

Full Width ​

Expand the component to fill its container with fullwidth.

Full width

States ​

Disabled ​

Prevents all interaction: click, drag-and-drop, and keyboard activation are all blocked.

Full width

Error State ​

Display a validation error with the error attribute. The error message replaces the helper text. Use semantic color values (success, error) to communicate validation state.

Full width

Form Integration ​

ore-file-input is a form-associated custom element. It serializes its selected files as FormData under the given name key: identical to how a native <input type="file"> behaves. Always include a name attribute when using the component inside a <form>: it is required for form submission.

html
<form id="upload-form" method="post" enctype="multipart/form-data">
  <ore-file-input name="documents" multiple accept=".pdf,.docx" label="Upload documents" required> </ore-file-input>
  <button type="submit">Submit</button>
</form>

Listening to the change event for reactive scenarios:

js
const fileInput = document.querySelector('ore-file-input');

fileInput.addEventListener('change', ({ detail }) => {
  console.log('Selected files:', detail.files);
});

fileInput.addEventListener('remove', ({ detail }) => {
  console.log('Removed:', detail.file.name);
  console.log('Remaining:', detail.files);
});

API Reference ​

Attributes ​

AttributeTypeDefaultDescription
acceptstring''Accepted MIME types or extensions (comma-separated)
color'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error'N/AColor theme
disabledbooleanfalseDisable all interaction
errorstring''Error message (replaces helper text)
fullwidthbooleanfalseExpand to full width
gallerybooleanfalseShow selected files as an image thumbnail/preview grid instead of a list
helperstring''Helper text below the dropzone
labelstring''Label text displayed above the dropzone
max-filesnumber0Maximum number of files (0 = unlimited)
max-sizenumber0Maximum file size in bytes (0 = unlimited)
multiplebooleanfalseAllow selecting multiple files
namestring''Form field name
requiredbooleanfalseMark as required
rounded'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl'N/ABorder radius
size'sm' | 'md' | 'lg''md'Component size
variant'solid' | 'flat' | 'bordered' | 'outline' | 'ghost''solid'Visual variant

Events ​

EventDetailDescription
change{ files: File[], originalEvent?: Event }Emitted when selection changes (add or remove)
remove{ file: File, files: File[] }Emitted when a file is removed from the list

CSS Parts ​

PartDescription
wrapperThe outer wrapper <div>
labelThe <label> element above the dropzone
dropzoneThe interactive drag-and-drop zone
inputThe hidden native <input type="file">
galleryThe preview grid <ul> (present instead of the plain file list when gallery is set)
helperThe helper text <div>
errorThe error text <div>

CSS Custom Properties ​

PropertyDescriptionDefault
--file-input-bgDropzone background colorVariant-dependent
--file-input-border-colorDropzone border colorVariant-dependent
--file-input-radiusBorder radiusvar(--radius)
--file-input-min-heightMinimum dropzone heightvar(--size-40)
--file-input-font-sizeFont sizevar(--text-sm)
--file-input-hover-bgDropzone background on hover (flat/ghost variants)Variant-dependent
--file-input-hover-border-colorDropzone border on hover (flat/bordered variants)Variant-dependent
--file-input-focus-bgDropzone background when focused/drag-over (flat)Variant-dependent
--file-input-focus-border-colorDropzone border when focused/drag-over (flat)Variant-dependent
--file-input-thumb-sizeGallery thumbnail width/height (min column size)var(--size-24)

Accessibility ​

The file input component follows WCAG 2.2 Level AA standards. The dropzone uses role="button" named from its own visible text via aria-labelledby (the label plus the "Drop files here" prompt), with aria-describedby linking helper text — there is no aria-label override, so the accessible name always contains the visible label text (WCAG SC 2.5.3). Tab focuses the dropzone; Enter / Space open the native file picker. Remove buttons inside the file list are individually focusable, each with a descriptive aria-label (e.g. "Remove report.pdf"). Error messages use role="alert" for live-region announcements. aria-disabled reflects the disabled state.

In gallery mode, thumbnail <img> elements use alt="" (decorative) rather than the file name: the name is already shown as a visible caption directly below each thumbnail, so screen readers get it from the caption in reading order instead of a duplicate, often-redundant alt (real filenames frequently contain words like "photo" or "image", which trips automated redundant-alt checks for no benefit).