Skip to content

File upload โ€‹

A drag-and-drop file uploader with previews, validation states and a built-in file list. Toggle Vue / CSS to switch the live demo and source together.

The look is Basecoat's .empty (the dropzone) and .item (the file rows) inside a .field (see Theme): a dashed rounded-lg drop target padded p-12 around a muted icon plate, a text-lg prompt and a text-sm/relaxed hint, over outlined rounded-md rows with a ghost icon button to remove each one. Dark mode is built in.

Upstream's empty state is genuinely large, so the default dropzone is taller than the pre-Basecoat one โ€” variant="compact" is the short one, and --mono-file-upload-dropzone-padding moves it in a line.

Basic โ€‹

Single-file upload with default styling.

Vue SFC

Compact โ€‹

Reduced padding via variant="compact".

Vue SFC

Title & subtitle โ€‹

The dropzone's two text lines are the title prop (default Klik atau seret file ke sini) and the subtitle prop (default Pilih file untuk diunggah). The old names placeholder and subtext are still accepted โ€” as attributes and as properties โ€” and write the same value.

For rich content, pass a slot="title" and/or slot="subtitle" child: each replaces one line, and a slot beats the prop of the same line. The whole dropzone opens the file picker, so stop the click on any link you put inside (@click.stop).

A title attribute is normally the browser's hover tooltip too; the uploader's inner root carries title="", so it never pops up over the field.

The secondary line renders as [mono-subtitle] and still carries the old [mono-subtext] hook (both are styled); its CSS variables keep their --mono-file-upload-subtext-* names. cssClass.subtitle (or the old cssClass.subtext) adds classes to it.

Vue SFC

Icon โ€‹

Replace the default ๐Ÿ“Ž with an iconify class via the icon prop (e.g. icon="i-mdi-cloud-upload"), or pass a slot="icon" child โ€” the slot wins over the prop. Use remove-icon for the file list's remove button.

Vue SFC

Multiple โ€‹

Allow multiple files with optional max-files / max-file-size.

Vue SFC

Image โ€‹

Image-only upload with previews.

Vue SFC

Validation โ€‹

Valid, invalid and warning states with messages.

Vue SFC

States โ€‹

Disabled and required examples.

Vue SFC

Preloaded โ€‹

Initialize the uploader with existing files.

Vue SFC

Event log โ€‹

Live log of change, remove and error events.

Vue SFC

Customized โ€‹

Override per-element styling with the cssClass prop (Vue) or extra utility classes (CSS).

Vue SFC

CSS Variables โ€‹

Vue SFC

Every uploader is themed through --mono-file-upload-* custom properties. Setting one on the element, on any wrapper/ancestor, or inline all work โ€” custom properties inherit, and they pierce the shadow-DOM boundary, so the same overrides apply to <mono-file-upload> and the shadow build. To re-skin globally, set the underlying tokens (--border, --muted, --primary, --destructive โ€ฆ) โ€” or switch flavor.

The two variants own separate knobs: everything below sizes default, and compact reads a --mono-file-upload-compact-* twin (-compact-padding, -compact-gap, -compact-icon-size, -compact-icon-glyph-size, -compact-icon-offset, -compact-title-font-size, -compact-title-line-height, -compact-list-gap, -compact-item-gap, -compact-item-padding-x, -compact-item-padding-y, -compact-file-gap, -compact-thumb-size, -compact-meta-font-size) โ€” so restyling one look never repaints the other.

VariableDefaultControls
--mono-file-upload-gap3 ร— --mono-spacingLabel โ†” dropzone โ†” list โ†” message
--mono-file-upload-dropzone-padding / -dropzone-gap12 ร— / 2 ร— --mono-spacingThe drop target's padding, and its title โ†” subtext gap
--mono-file-upload-border-color (alias -border) / -border-width / -border-style--border / --mono-border-width / dashedThe dashed edge
--mono-file-upload-dropzone-bg (alias -background) / -dropzone-hover-bgtransparent / --mono-mode-ghost-hoverDrop-target fill, resting and hovered
--mono-file-upload-radius--mono-radius-lgDrop-target corner
--mono-file-upload-icon-size / -icon-glyph-size / -icon-offset10 ร— / 6 ร— / 4 ร— --mono-spacingThe icon plate, its glyph, and the space below it
--mono-file-upload-icon-bg / -icon-color / -icon-radius--muted / --foreground / --mono-radius-lgThe icon plate's paint
--mono-file-upload-title-font-size / -title-line-height / -title-font-weight / -title-tracking / -title-transform--mono-text-lg / its lh / medium / --mono-tracking-tight / noneThe prompt
--mono-file-upload-subtext-font-size / -subtext-line-height / -subtext-color--mono-text-sm / --mono-leading-relaxed / --muted-foregroundThe hint (the subtitle line โ€” the vars keep the old name)
--mono-file-upload-list-gap2.5 ร— --mono-spacingRow โ†” row
--mono-file-upload-item-bg (alias -surface) / -item-border-color / -item-border-width / -item-radiustransparent / --border / --mono-border-width / --mono-radius-mdA file row's box
--mono-file-upload-item-gap / -item-padding-x / -item-padding-y / -item-font-size / -file-gap2.5 ร— / 3 ร— / 2.5 ร— / --mono-text-sm / 1 ร— --mono-spacingA file row's metrics
--mono-file-upload-thumb-size / -thumb-radius / -thumb-bg / -thumb-color8 ร— --mono-spacing / --mono-radius-sm / --muted / --muted-foregroundThe preview square
--mono-file-upload-name-* / -meta-*--mono-text-sm medium / --mono-text-sm mutedFile name and size type
--mono-file-upload-remove-size / -remove-radius8 ร— --mono-spacing / min(--mono-radius-md, 10px)The remove button (a ghost icon button)
--mono-file-upload-message-font-size / -message-line-height / -message-color--mono-text-sm / --mono-leading-normal / --muted-foregroundHelper and validation text
--mono-file-upload-label-* / -required-color--mono-text-sm medium / --destructiveThe label row
--mono-file-upload-ring-color / -ring-width / -ring-alpha--ring / --mono-ring-width / --mono-ring-alphaThe drag-over and focus rings
--mono-file-upload-primary / -success / -danger / -warning / -text / -muted--primary / --success / --destructive / --warning / --foreground / --muted-foregroundThe roles

Deprecated and honoured as no-ops until 2.0: every --mono-file-upload-*-rgb (use color-mix). --mono-file-upload-border, -background and -surface still work as the fallbacks noted above.

Types โ€‹

Importimport { FileUploadProps } from 'mono-helper'
PropValueDefaultDescription
labelstringโ€”Field label shown above the dropzone.
helperTextstringโ€”Helper text shown below the dropzone.
titlestringโ€”Primary prompt text inside the dropzone. `slot="title"` replaces it. Default `'Klik atau seret file ke sini'`.
subtitlestringโ€”Secondary hint text inside the dropzone. `slot="subtitle"` replaces it. Default `'Pilih file untuk diunggah'`.
placeholderstringโ€”โ€”
subtextstringโ€”โ€”
acceptstringโ€”Accepted file types for the file input.
iconstringโ€”Dropzone icon. An iconify utility class (e.g. `i-mdi-cloud-upload`) renders the icon; any other string renders as text/emoji. A `slot="icon"` child takes priority over this prop.
removeIconstringโ€”Remove (โœ•) button icon โ€” iconify class or text.
multiplebooleanโ€”Allows selecting multiple files at once.
disabledbooleanโ€”Disables interaction and dims the component.
requiredbooleanโ€”Marks the field as required with an indicator.
dragdropbooleanโ€”Enables drag-and-drop file selection.
maxFileSizenumberโ€”Maximum allowed size per file, in bytes.
maxFilesnumberโ€”Maximum number of files allowed.
modelValueFileUploadItem[]โ€”Two-way bound list of selected files.
variant'default' | 'compact'โ€”Layout style: default or compact.
validationState'warning' | 'default' | 'valid' | 'invalid'โ€”Validation state styling the component.
validationMessagestringโ€”Validation message shown below the dropzone.
cssClassFileUploadCssClassโ€”Per-element class overrides for internal parts.
visiblebooleanโ€”Whether the control is shown. Defaults to `true`.
visibleType'none' | 'invisible'โ€”How it hides when `visible` is `false`. Defaults to `'none'`.