Playground

File upload

Choose files by browsing or dropping them, and see what is selected.

  • Built on native elements
  • A native file input stays focusable and operable by keyboard; the drop zone is a label for it.
  • Selected files are listed as text with a Remove button each; changes are announced via a polite status.
  • Dragging is an extra, never the only way.
  • Styles in one file: file-upload.css

Import

import '@monoline/css';
import {FileUpload} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add file-upload

Usage

import {FileUpload} from '@monoline/react';

<div style={{maxWidth: '420px'}}>
  <FileUpload multiple accept="image/*,.pdf" label="Drop files here or choose" />
</div>

Examples

Multiple files

Props

FileUploadProps

PropTypeDefaultDescription
labelReactNode'Drop files here or choose'The visible prompt, for example "Drop files here or choose".
onFilesChange((files: File[]) => void)–Called with the full current list whenever it changes.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

AttributeStylesheet
[data-over]file-upload.css

CSS classes

ClassStylesheet
.uploadfile-upload.css
.upload-listfile-upload.css
.upload-namefile-upload.css
.upload-removefile-upload.css
.upload-zonefile-upload.css
.btn02-buttons.css
.btn-block02-buttons.css
.btn-danger02-buttons.css
.btn-ghost02-buttons.css
.btn-lg02-buttons.css
.btn-line02-buttons.css
.btn-sm02-buttons.css
.btn-solid02-buttons.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.upload {
  border-color: var(--accent);
}
.upload[data-over] {
  background: var(--wash);
}

Accessibility

  • A native file input stays focusable and operable by keyboard; the drop zone is a label for it.
  • Selected files are listed as text with a Remove button each; changes are announced via a polite status.
  • Dragging is an extra, never the only way.