Skip to main content

Starwind UI v1.12 is now available!

Dropzone

Installation

Usage

Info

No dropped files on this page are uploaded anywhere.

Default

The default Dropzone component displays a cloud upload icon with a prompt to upload files, and shows what files have been selected.

Custom Content

The dropzone components can be customized through slots. The default <Dropzone /> component has the following three components in the slot if nothing is passed:

<DropzoneUploadIndicator />
<DropzoneLoadingIndicator />
<DropzoneFilesList />

The DropzoneUploadIndicator and DropzoneLoadingIndicator each have their own slots to customize the upload and loading indicators. The DropzoneFilesList component can be passed any classes to use.

Loading

Nothing is actually uploaded when a file is selected, as internally a standard html <input type="file"> is used. To show a loading indication initially, you can use the isUploading prop.

You can also use the data-is-uploading attribute to show or hide a loading indicator at any time. This is useful if you want to show a loading indicator while a file is actually being uploaded (like on form submission).

Accept Specific File Types

You can limit the types of files that users can select by using the accept attribute.

Multiple Files

Allow users to select multiple files by using the multiple attribute.

API Reference

Dropzone

The main Dropzone component wraps the entire file upload interface.

PropTypeDefault
idstringAuto-generated
acceptstring-
multiplebooleanfalse
disabledbooleanfalse
requiredbooleanfalse
namestring-
isUploadingbooleanfalse
classstring-
<Dropzone accept="image/*" multiple />

Additional Notes:

  • id: Unique identifier for the element. Assigns the ID to the <label> element, and the <input> element gets the same ID with “-input” suffix
  • accept: File types the input should accept (e.g., “image/*”, “.pdf”)
  • isUploading: Whether to show the loading indicator
  • The component provides a default slot to customize content. By default includes DropzoneUploadIndicator, DropzoneLoadingIndicator, and DropzoneFilesList

DropzoneFilesList

Displays the list of uploaded files.

PropTypeDefault
classstring-
<DropzoneFilesList />

DropzoneUploadIndicator

Displays the upload icon and text that are shown when no files are being uploaded.

PropTypeDefault
classstring-
<DropzoneUploadIndicator>
<span>Custom upload message</span>
</DropzoneUploadIndicator>

DropzoneLoadingIndicator

Displays a loading spinner and text for use when files are being uploaded.

PropTypeDefault
classstring-
<DropzoneLoadingIndicator>
<span>Custom loading message</span>
</DropzoneLoadingIndicator>

Changelog

v1.2.0

  • style and focus state updates

v1.1.0

  • Add a data-slot attribute to all components to enable global styling updates

v1.0.0

  • Initial release with starwind v1.7.0