Skip to main content

Starwind UI v3.0 beta is now available! Read the migration guide

Dropzone Primitive

Dropzone is a Starwind Runtime primitive in the form-value-control contract family.

Anatomy

Use the Astro primitive adapter to render Dropzone anatomy with the Runtime wiring included.

---
import { Dropzone } from "@starwind-ui/astro/dropzone";
---
<Dropzone.Root>
<Dropzone.Input />
<Dropzone.UploadIndicator>Drop files here</Dropzone.UploadIndicator>
<Dropzone.LoadingIndicator>Uploading...</Dropzone.LoadingIndicator>
<Dropzone.FilesList />
</Dropzone.Root>

API Reference

Root

The main element that owns the Dropzone Runtime instance.

Default element
label
Discovery hook
data-sw-dropzone
Role
button

Props

Prop Type Default Toggle
disabled boolean false
Description
Disables the Root part.
Kind
option
Targets
-
Full type
boolean
isUploading boolean false
Description
Controls whether Dropzone is uploading.
Kind
control
Targets
root, uploadIndicator, loadingIndicator
Full type
boolean
onFilesChange (files: File[], details: DropzoneFilesChangeDetails) => void -
Description
Runs when selected files change for Dropzone.
Kind
callback
Targets
-
Full type
(files: File[], details: DropzoneFilesChangeDetails) => void

Events

Event Callback Value Toggle
filesChange onFilesChange files: File[]
Description
Fires when selected files change for Dropzone.
DOM event
starwind:files-change
Details type
DropzoneFilesChangeDetails
Timing
-
Cancelable
No

State

State Type Props Toggle
uploading boolean isUploading
Description
Tracks whether Dropzone is uploading files.
Initial attribute
data-is-uploading
Runtime getter
getUploading
Runtime setter
setUploading
State control support
React supports controlled state with the isUploading prop. Runtime/HTML reads initial state from data-is-uploading and updates with setUploading. Astro adapters render initial/default state and report changes through Runtime DOM events.

Data Attributes

Runtime hooks
Attribute Value Description
data-sw-dropzone - Marks the Root part so Starwind Runtime can find it.
State
Attribute Value Description
data-drag-active - Reflects the drag active state on the Root part.
data-has-files - Reflects the has files state on the Root part.
Metadata
Attribute Value Description
data-disabled - Reflects the disabled prop on the Root part.
data-is-uploading - Reflects the uploading prop on the Root part.

Input

The native input synchronized by Dropzone.

Default element
input
Discovery hook
data-sw-dropzone-input
Role
-

Props

Prop Type Default Toggle
accept string -
Description
Limits which file types can be selected.
Kind
attribute
Targets
input
Full type
string
multiple boolean -
Description
Allows multiple Dropzone values to be selected.
Kind
attribute
Targets
input
Full type
boolean
name string -
Description
Sets the submitted form field name.
Kind
attribute
Targets
input
Full type
string
required boolean -
Description
Marks the form control as required.
Kind
attribute
Targets
input
Full type
boolean

Data Attributes

Runtime hooks
Attribute Value Description
data-sw-dropzone-input - Marks the Input part so Starwind Runtime can find it.
Metadata
Attribute Value Description
data-disabled - Reflects the disabled prop on the Input part.

Upload Indicator

Upload progress indicator shown by Dropzone.

Default element
div
Discovery hook
data-sw-dropzone-upload-indicator
Role
-

Props

Prop Type Default Toggle
isUploading boolean false
Description
Controls whether Dropzone is uploading.
Kind
control
Targets
root, uploadIndicator, loadingIndicator
Full type
boolean

State

State Type Props Toggle
uploading boolean isUploading
Description
Tracks whether Dropzone is uploading files.
Initial attribute
data-is-uploading
Runtime getter
getUploading
Runtime setter
setUploading
State control support
React supports controlled state with the isUploading prop. Runtime/HTML reads initial state from data-is-uploading and updates with setUploading. Astro adapters render initial/default state and report changes through Runtime DOM events.

Data Attributes

Runtime hooks
Attribute Value Description
data-sw-dropzone-upload-indicator - Marks the Upload Indicator part so Starwind Runtime can find it.
State
Attribute Value Description
data-is-uploading - Reflects the uploading state on the Upload Indicator part.

Loading Indicator

Loading indicator shown by Dropzone.

Default element
div
Discovery hook
data-sw-dropzone-loading-indicator
Role
-

Props

Prop Type Default Toggle
isUploading boolean false
Description
Controls whether Dropzone is uploading.
Kind
control
Targets
root, uploadIndicator, loadingIndicator
Full type
boolean

State

State Type Props Toggle
uploading boolean isUploading
Description
Tracks whether Dropzone is uploading files.
Initial attribute
data-is-uploading
Runtime getter
getUploading
Runtime setter
setUploading
State control support
React supports controlled state with the isUploading prop. Runtime/HTML reads initial state from data-is-uploading and updates with setUploading. Astro adapters render initial/default state and report changes through Runtime DOM events.

Data Attributes

Runtime hooks
Attribute Value Description
data-sw-dropzone-loading-indicator - Marks the Loading Indicator part so Starwind Runtime can find it.
State
Attribute Value Description
data-is-uploading - Reflects the uploading state on the Loading Indicator part.

Files List

Lists the selected files for Dropzone.

Default element
div
Discovery hook
data-sw-dropzone-files-list
Role
-

Data Attributes

Runtime hooks
Attribute Value Description
data-sw-dropzone-files-list - Marks the Files List part so Starwind Runtime can find it.
State
Attribute Value Description
data-has-files - Reflects the has files state on the Files List part.

Runtime API

Factory
createDropzone
Import
@starwind-ui/runtime/dropzone
Root hook
root data-sw-dropzone
Option props
disabled, isUploading, onFilesChange

Option Lifecycles

OptionLifecycle
disabledsetter-backed
isUploadingsetter-backed
onFilesChangeconstructor-only

Runtime Setters

Method Target Description
setDisabled prop: disabled Updates whether Dropzone is disabled from Runtime code.
setUploading prop: isUploading Updates whether Dropzone is uploading files from Runtime code.

Form Participation

FactValue
Form propsaccept, multiple, name, required
Hidden inputinput (file)
Field integrationNo
Component Relationship
Dropzone Direct primitive