- Plugins
- File Upload
Plugins
Tailwind CSS File Upload Plugin API
Headless, unstyled File Upload plugin built with JavaScript and TypeScript, including installation, usage, options, methods, events, and selectors.
Installation
To get started, install File Upload plugin via npm, or skip this step if you are already using Preline UI as a package.
npm i lodash dropzone @preline/file-upload
Example
Here is a basic example of a file upload with advanced features.
.
Pick a photo up to 2MB.
Data Options
Dropzone.js
Please note that this component requires the use of the Dropzone.js plugin. Most options available in the plugin are available in our wrapper.
Methods
The HSFileUpload object is contained within the global window object
Destroy instance.
const { element } = HSFileUpload.getInstance('#file-upload', true);
const destroyBtn = document.querySelector('#destroy-btn');
destroyBtn.addEventListener('click', () => {
element.destroy();
});
Events
Dropzone.js
Please note that this component requires the use of the Dropzone.js plugin. Most events available in the plugin are available in our wrapper.
When item successfully uploaded to the server event example.
const { element } = HSFileUpload.getInstance('#hs-file-upload', true);
const { dropzone } = element;
dropzone.on('complete', () => {
console.log('Item uploaded!');
});
Demo examples
Looking for prebuilt UI components based on the Tailwind CSS? Preline UI packs hundreds of component examples for all your website needs.