DocsComponentsTemplatesThemesGitHub

FileUpload

Click-or-drop zone with a visible label, custom title, hint, sizes and error; pair with FileItem rows.

Code

import * as React from 'react';
import { FileUpload } from '@fruit-labs/design';

export default function Demo() {
  return (
    <div
      style={{
        display: 'flex',
        flexDirection: 'column',
        gap: 16,
        maxWidth: 440,
      }}
    >
      <FileUpload label="Attachments" hint="PNG, JPG or PDF up to 10 MB" multiple />
      <FileUpload
        label="Logo"
        size="sm"
        required
        title={
          <span>
            <b>Upload logo</b>
            {' · SVG or PNG'}
          </span>
        }
        error="Add a logo to continue."
      />
    </div>
  );
}

Install

From npm:

npm install @fruit-labs/design

import { FileUpload } from '@fruit-labs/design';

Or copy the TypeScript source into your project:

npx shadcn@latest add https://design.fruitlabs.online/r/file-upload.json

Guidelines

  • label is the visible field label (and names the zone for screen readers); title replaces the 'Choose a file or drag it here' text; ariaLabel only when there's no visible label.
  • State accepted types and size in hint. size="sm" is a one-line zone for dense forms.

Props

PropTypeRequired
onFiles(files: File[]) => voidNo
acceptstringNo
multiplebooleanNo
labelReact.ReactNodeNo
titleReact.ReactNodeNo
hintstringNo
errorReact.ReactNodeNo
requiredbooleanNo
size'sm' | 'md'No
disabledbooleanNo
ariaLabelstringNo
classNamestringNo
styleReact.CSSPropertiesNo

Edit this example on GitHub