1.1.0 • Published 1 year ago

dragbox v1.1.0

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
1 year ago

📦 DragBox

Easily add a drag and drop field to your app!

Installation

HTML

<div class="dragbox"></div>

JavaScript

const DragBox = require('dragbox');

new DragBox('.dragbox');

Parameters

NameDescriptionTypeDefault
elementElement or selectorElement or String(Required)
optionsOptionsObject{}
options.acceptList of accepted mime typesString or Array[]
options.maxFilesMaximum number of files to accept. Setting to 1 makes preview different.IntegerInfinity
options.textDragText for drag and drop hintString'Drag and drop here'
options.textOrText for "or"String'or'
options.textSelectText for file select buttonString'Browse files'
options.iconFileIcon HTML for fileHTML'<i class="fa-regular fa-file"></i>'
options.iconRemoveIcon HTML for remove buttonHTML'<i class="fa-solid fa-xmark"></i>'
options.onAddCallback when files are addedFunction()=>{}
options.onRemoveCallback when files are removedFunction()=>{}

Access Input

You can access the input element in two ways:

let dragbox = new DragBox('.dragbox');
dragbox.input; // HTMLInputElement
document.querySelector('.dragbox > input');

Styling

There is a default CSS file. You can import it by using this on your <head> element.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dragbox/index.css">

The primary color is the --color variable. You can change it using one of these methods:

<div class="dragbox" style="--color: blueviolet">
.dragbox {
    --color: blueviolet;
}
1.1.0

1 year ago

1.0.4

2 years ago

1.0.4-beta

2 years ago

1.0.2-beta

2 years ago

1.0.1-beta

2 years ago

1.0.0-beta

2 years ago

1.0.0

3 years ago