Skip to content

File Input ​

Use bo-file-input for compact native file selection. It renders a native <input type="file">, displays selected file rows, validates accepted types and limits, and lets users remove selected files.

Basic Usage ​

The input starts empty. v-model is File | null for a single file and File[] for a multiple input. The browser controls how files are selected; the live examples become selected after you choose a file.

Choose a file to attach.
<bo-file-input label="Attachments" description="Choose a file to attach." />

Selected File ​

Bind v-model to observe the selected file. After a selection, the component renders the file name and a Remove action.

Choose a PDF or PNG file.
<bo-file-input>
  v-model="selectedFile"
  label="Selected file"
  accept=".pdf,.png"
/>

Multiple Files ​

Set multiple to allow more than one file. maxFiles limits the number accepted by the selection composable and is measured in files.

Up to four PDF or PNG files
No files selected.
<bo-file-input>
  v-model="multipleFiles"
  label="Attachments"
  description="Up to four PDF or PNG files"
  accept=".pdf,.png"
  multiple
  :max-files="4"
/>

Accepted Types ​

Pass the native accept value to limit the file picker. MIME types, extensions, and comma-separated combinations are supported by the browser.

<bo-file-input>
  v-model="imageFile"
  label="Profile image"
  accept="image/*"
/>

Disabled, Full Width, and Error ​

Use disabled to prevent selection, fullWidth when the control should participate in a full-width form layout, and error to show a validation message. required adds the native required state and visual marker.

A project document is required.
<bo-file-input label="Disabled input" disabled />
<bo-file-input>
  label="Required upload"
  full-width
  required
  error="A project document is required."
/>

Limits and Validation ​

maxSize is measured in bytes. When a selection violates accept, maxFiles, or maxSize, the component displays the validation error and emits error. The error prop is useful for server-side or external validation.

Usage Guidance ​

  • Always give a file input a visible label or an ariaLabel.
  • Tell users which formats and size limits are accepted before they open the picker.
  • Use multiple only when the receiving workflow can handle an array of files.
  • Validate file content and permissions on the server as well as in the browser.

API Reference ​

Props ​

PropTypeDefaultDescription
idstringAutogeneratedNative input id.
dataTestIdstringAutogeneratedThe test id attribute.
namestring-Native form field name.
acceptstring-Accepted MIME types or file extensions.
multiplebooleanfalseAllows multiple files and returns an array.
maxFilesnumber-Maximum number of files accepted.
maxSizenumber-Maximum file size in bytes.
labelstring-Visible input label.
descriptionstring-Supporting text below the label.
errorstring-External validation message.
hintstring-Supporting hint when there is no error.
requiredbooleanfalseNative required state.
disabledbooleanfalsePrevents file selection.
fullWidthbooleanfalseFull-width form layout option.
ariaLabelHTMLAttributes['aria-label']-Accessible name when a visible label is not used.
modelValueFile | File[] | nullnullSelected file value used by v-model.

Events ​

EventPayloadDescription
update:modelValueFile | File[] | nullEmitted when the selection or removal changes.
changeFile[]Emitted after selection or removal.
errorstringEmitted when selection validation fails.

Exposed Methods ​

MethodSignatureDescription
focus() => voidOpens the native file picker.
reset() => voidClears selected files and the input.

Released under the MIT License.