logo polydile logo polydile en modo oscuro dile-components

dile-drop-file

This custom element provides a file upload field with drag-and-drop support, single file selection, preview, and extension validation. It integrates seamlessly with HTML forms for greater versatility, offering a rich user experience.

The component also offers a button to manually select a file and a clear option to remove the uploaded file. It's designed to simplify file handling in web applications while ensuring validation.

Install

npm install @dile/ui

Usage

Import the component.

import "@dile/ui/components/drop-file/drop-file.js"

Use the component

<dile-drop-file 
  name="fileinput"
  id="myFileInput" 
  label="Image to upload" 
  message="Select an image and press upload button"
></dile-drop-file>

Properties

Methods

CSS Custom Properties

You can customize it using CSS Custom Properties.

Custom property Description Default
--dile-drop-zone-min-height Minimum height of the drop zone auto
--dile-input-label-margin-bottom Margin-bottom for the label 4px
--dile-input-label-font-size Font size for the label 1em
--dile-input-label-color Color of the label #59e
--dile-input-label-font-weight Font weight of the label normal
--dile-input-section-width Width of the input section 100%
--dile-drop-zone-border-color Drop section border color #ccc

Custom Events

Example

Simple File Drop Zone

<script type="module">
import "@dile/ui/components/drop-file/drop-file.js"
</script>
<dile-drop-file label="Upload your file" dropLabel="Drop your file here"></dile-drop-file>