Skip to content

File Uploader

Last updated 27 Oct 2026

NbFileUploader lets users select or drag files into your app. It replaces the native <input type="file"> with a consistent, accessible widget that includes heading, description, upload states (loading, success, error), and drag-and-drop support.

Basic Usage ​

vue
<template>
  <NbFileUploader
    heading="Upload files"
    description="Max file size is 500 KB. Supported file types are .jpg, .png, and .pdf."
    button-label="Add file"
    accept=".jpg,.png,.pdf"
    :max-size="512000"
  />
</template>

Variants ​

The variant prop sets the accent color on the button and the drag-over drop zone. Every NbButton variant is supported.

vue
<template>
  <NbFileUploader variant="primary" button-label="Add file" />
  <NbFileUploader variant="danger" button-label="Add file" />
  <NbFileUploader variant="success" button-label="Upload" />
</template>

Multiple Files ​

Set multiple to allow selecting more than one file at a time.

vue
<template>
  <NbFileUploader multiple button-label="Add files" />
</template>

File States ​

Each file in the list can be in one of three states, controlled via the setFileStatus method on the component instance:

StateVisual
idleFilename with X to remove
loadingAnimated spinner (no remove button)
successFilled checkmark icon

Validation errors (size, type) are shown immediately on drop/select with a red border and error message below the filename.

vue
<template>
  <NbFileUploader ref="uploader" button-label="Add file" :max-size="512000" />
</template>
ts
// After starting your upload request:
uploader.value.setFileStatus(0, 'loading')

// On success:
uploader.value.setFileStatus(0, 'success')

// On server-side error:
uploader.value.setFileStatus(0, 'idle', 'Upload failed. Please try again.')

Validation ​

Client-side validation runs automatically on file select and drop:

  • maxSize - rejects files larger than the specified number of bytes.
  • accept - rejects files whose extension does not match the accept string.

Rejected files are still added to the list with an error state so the user can see what went wrong and remove them.

vue
<template>
  <NbFileUploader accept=".jpg,.png" :max-size="204800" />
</template>

Disabled ​

Set disabled while the files cannot be taken, for instance while a form is saving. The trigger and the hidden file input are disabled, so neither a click nor the keyboard opens the picker, and Tab skips the trigger. Dragging a file over the component shows no drop zone and a not-allowed cursor, and a drop is ignored. Files already in the list stay, and their remove buttons are disabled too, so the list cannot change until the uploader is enabled again.

The trigger takes the disabled look of every NbButton, and the heading, description and file list dim to the opacity disabled fields use.

vue
<template>
  <NbFileUploader heading="Upload files" :disabled="saving" />
</template>

Events ​

EventPayloadDescription
changeFile[]Emitted after any file add or remove (valid files only)
removeFileEmitted when a file is removed from the list
vue
<template>
  <NbFileUploader @change="onFilesChanged" @remove="onFileRemoved" />
</template>

Props ​

PropTypeDefaultDescription
headingstring-Bold heading above the component
descriptionstring-Helper text with a left border accent
buttonLabelstring'Add file'Label for the upload trigger button
variant'primary' | 'secondary' | 'ghost' | 'danger' | 'success' | 'warning''primary'Accent color from NbButton variants
acceptstring-Native accept attribute (e.g. .jpg,.pdf)
multiplebooleanfalseAllow selecting multiple files
maxSizenumber-Max file size in bytes for client validation
disabledbooleanfalseIgnore clicks, the keyboard and drops

Exposed ​

NameTypeDescription
filesRef<FileItem[]>Reactive list of file items
setFileStatus(index, status, error?) => voidProgrammatically update a file's state