Skip to content

Data Input

FileInput

File picker dropzone with accept and size constraints.

import { FileInput } from '@var-ui/react';
Choose file

FileInput

File picker dropzone with click-to-browse, drag-and-drop, and client-side accept / maxSize / maxFiles validation. Always controlled via value and onValueChange.

Examples

Default

Pass a required label, controlled value / onValueChange, and optional accept filters.

Choose file
Demo.tsxTSX
import { FileInput } from '@var-ui/react';

<FileInput label="Upload" value={file} onValueChange={setFile} accept=".pdf,image/*" />

Multiple files

Set multiple so value is a File[] (or null when cleared). Optionally cap the count with maxFiles.

Choose files

Select one or more files

Demo.tsxTSX
import { FileInput } from '@var-ui/react';
import { useState } from 'react';

const [files, setFiles] = useState<File[] | null>(null);

<FileInput
  label="Attachments"
  value={files}
  onValueChange={setFiles}
  multiple
  accept="image/*,.pdf"
/>

Sizes

size (sm, md, lg) scales the dropzone padding, text and icon. It falls back to the surrounding control size (InputGroup, Toolbar, Select.Root), then md.

Props

Accessibility

The dropzone is a focusable role="button" activated with Enter/Space, labelled by the visible field label and described by description / error text. The native file input is visually hidden (aria-hidden) and opened programmatically. The clear control has an explicit aria-label (“Clear …”).

FileTrigger

FileTrigger opens the picker from an existing button. It does not render a dropzone, filename, or field label, and it does not take value. onSelect receives the chosen files. Choosing the same file again calls onSelect again.

TSX
<FileTrigger accept="image/*" multiple onSelect={(files) => upload(files)}>
  <Button>Choose images</Button>
</FileTrigger>