Tailwind CSS File Upload
File Upload enhances web forms with a Tailwind CSS-compatible, user-friendly interface that supports drag-and-drop, previews, and progress bars. It allows simultaneous multiple file uploads with options for automatic or manual submission and validation of file types and sizes.
Requires Additional Installation
Note that this component requires the use of the third-party Dropzone plugin.
Requires JS
Note that this component requires the use of Preline UI's File Upload plugin, else you can skip this message if you are already using Preline UI as a package.
Installation
-
Install Dropzone.
Install
dropzonevia npmTerminalnpm i dropzone -
Add Lodash and Dropzone to the page.
Include the JavaScript
<script>near the end of your</body>tag:HTMLCertain JavaScript Helpers in Preline UI make use of Lodash plugin. Don't forget to install it, if you haven't done so already:
npm i lodash
Default file upload
Start with a dropzone-style uploader that supports previews, progress, and file removal.
File size validation
Validate uploads and show an error state when a selected file exceeds the configured size limit.
Single-image upload
Use a single-file image uploader for avatars, profile photos, or other one-image updates.
Input-style file picker
Use a compact input-style trigger when you only need single-file selection and a filename display.
Destroy and reinitialize
Use the destroy method to remove a file upload instance, then initialize it again when needed.