File upload
Choose files by browsing or dropping them, and see what is selected.
SourceStyles source@monoline/react 0.5.0Markdown for AI toolsstable
- 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
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | '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.
| Attribute | Stylesheet |
|---|---|
[data-over] | file-upload.css |
CSS classes
| Class | Stylesheet |
|---|---|
.upload | file-upload.css |
.upload-list | file-upload.css |
.upload-name | file-upload.css |
.upload-remove | file-upload.css |
.upload-zone | file-upload.css |
.btn | 02-buttons.css |
.btn-block | 02-buttons.css |
.btn-danger | 02-buttons.css |
.btn-ghost | 02-buttons.css |
.btn-lg | 02-buttons.css |
.btn-line | 02-buttons.css |
.btn-sm | 02-buttons.css |
.btn-solid | 02-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.