Skip to content

Image Picker

Last updated 28 Oct 2026

NbImagePicker shows one picture in a box and lets people add, replace or remove it, by clicking or by dropping a file. It is for company logos, avatars and any other "add a picture" spot. It emits the chosen file and never uploads it.

Basic usage ​

The picker holds nothing: pass the current image in as src (a URL or a data URL), and handle pick and remove yourself. Upload in pick, and set src to what you now hold.

vue
<template>
  <NbImagePicker
    :src="logoUrl"
    alt="Company logo"
    label="Add logo"
    remove-label="Remove logo"
    :loading="uploading"
    :max-size="200 * 1024"
    @pick="upload"
    @remove="remove"
    @reject="onReject"
  />
</template>

<script setup lang="ts">
import { ref } from 'vue'

const logoUrl = ref('')
const uploading = ref(false)

async function upload(file: File) {
  uploading.value = true
  try {
    logoUrl.value = await api.uploadLogo(file)
  } finally {
    uploading.value = false
  }
}

async function remove() {
  await api.deleteLogo()
  logoUrl.value = ''
}

function onReject({ file, reason }: { file: File; reason: 'type' | 'size' }) {
  // Say why, in the product's words.
}
</script>

Limits ​

accept takes what <input accept> takes and defaults to image/*. max-size is in bytes. A file that fails either check is not emitted as pick: the picker emits reject with the file and the reason ('type' or 'size'), and the product says why in its own words. The same checks apply to a dropped file, which the browser does not check itself.

Size and shape ​

size is the width: a number is pixels, a string is any CSS length. ratio is the shape, as a CSS aspect-ratio, square by default. fit is contain (all of the image, right for a logo) or cover (fills the box and crops, right for a photo).

Loading and disabled ​

loading covers the picker with a spinner and blocks picking, dropping and removing while your upload runs. disabled blocks all of it and dims the box.

Props ​

PropTypeDefaultDescription
srcstring''Current image, as a URL or data URL
altstring''What the image shows, for a screen reader
labelstring'Add image'Text in the empty drop target
dropLabelstring'Drop to upload'Text while a file is dragged over
replaceLabelstring'Replace image'Accessible name of the picker when it has an image
removeLabelstring'Remove image'Tooltip and accessible name of the remove button
acceptstring'image/*'File types taken, as for <input accept>
maxSizenumber-Largest file taken, in bytes
removablebooleantrueDraw the remove button while there is an image
removeDisabledbooleanfalseKeep the remove button but make it unavailable
loadingbooleanfalseSpinner over the picker, and block it
disabledbooleanfalseBlock the picker
sizenumber | string'10rem'Width of the box
ratiostring'1 / 1'Shape of the box, as a CSS aspect-ratio
fit'contain' | 'cover''contain'How the image sits in the box

Events ​

EventPayloadDescription
pickFileA file passed the checks. Upload it, then set src
remove-The remove button was pressed
reject{ file: File, reason: 'type' | 'size' }A file was turned away

Exposed ​

open() opens the file dialog, for a button of your own elsewhere on the page.