Tailwind CSS Image And File Upload Example

In this tutorial we will create Image upload and file upload, attach file upload, responsive file upload, examples with Tailwind CSS

Tool Use

Tailwind CSS 2.x

Heroicons Icons

? View Demo

Setup Project
Using CDN

&…


This content originally appeared on DEV Community and was authored by larainfo

In this tutorial we will create Image upload and file upload, attach file upload, responsive file upload, examples with Tailwind CSS

Tool Use

Tailwind CSS 2.x
Heroicons Icons

? View Demo

Setup Project
Using CDN

<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">

or

The Easiest way to install Tailwind CSS with Tailwind CLI

How to Install Tailwind CSS with NPM

Example 1

Image File Upload

<div class="flex justify-center mt-8">
    <div class="rounded-lg shadow-xl bg-gray-50 lg:w-1/2">
        <div class="m-4">
            <label class="inline-block mb-2 text-gray-500">Upload
                Image(jpg,png,svg,jpeg)</label>
            <div class="flex items-center justify-center w-full">
                <label class="flex flex-col w-full h-32 border-4 border-dashed hover:bg-gray-100 hover:border-gray-300">
                    <div class="flex flex-col items-center justify-center pt-7">
                        <svg xmlns="http://www.w3.org/2000/svg"
                            class="w-12 h-12 text-gray-400 group-hover:text-gray-600" viewBox="0 0 20 20"
                            fill="currentColor">
                            <path fill-rule="evenodd"
                                d="M4 3a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V5a2 2 0 00-2-2H4zm12 12H4l4-8 3 6 2-4 3 6z"
                                clip-rule="evenodd" />
                        </svg>
                        <p class="pt-1 text-sm tracking-wider text-gray-400 group-hover:text-gray-600">
                            Select a photo</p>
                    </div>
                    <input type="file" class="opacity-0" />
                </label>
            </div>
        </div>
        <div class="flex p-2 space-x-4">
            <button class="px-4 py-2 text-white bg-red-500 rounded shadow-xl">Cannel</button>
            <button class="px-4 py-2 text-white bg-green-500 rounded shadow-xl">Create</button>
        </div>
    </div>
</div>

Alt Text

Example 2

Attach File Upload

<div class="flex justify-center mt-8">
    <div class="max-w-2xl rounded-lg shadow-xl bg-gray-50">
        <div class="m-4">
            <label class="inline-block mb-2 text-gray-500">File Upload</label>
            <div class="flex items-center justify-center w-full">
                <label
                    class="flex flex-col w-full h-32 border-4 border-blue-200 border-dashed hover:bg-gray-100 hover:border-gray-300">
                    <div class="flex flex-col items-center justify-center pt-7">
                        <svg xmlns="http://www.w3.org/2000/svg" class="w-8 h-8 text-gray-400 group-hover:text-gray-600"
                            fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" />
                        </svg>
                        <p class="pt-1 text-sm tracking-wider text-gray-400 group-hover:text-gray-600">
                            Attach a file</p>
                    </div>
                    <input type="file" class="opacity-0" />
                </label>
            </div>
        </div>
        <div class="flex justify-center p-2">
            <button class="w-full px-4 py-2 text-white bg-blue-500 rounded shadow-xl">Create</button>
        </div>
    </div>
</div> 

Alt Text

See Also ?

10+ Free Tailwind CSS Colors Tools Resources for 2021
Tailwind CSS Simple Table Example
Tailwind CSS Simple Button Examples


This content originally appeared on DEV Community and was authored by larainfo


Print Share Comment Cite Upload Translate Updates
APA

larainfo | Sciencx (2021-08-25T04:06:26+00:00) Tailwind CSS Image And File Upload Example. Retrieved from https://www.scien.cx/2021/08/25/tailwind-css-image-and-file-upload-example/

MLA
" » Tailwind CSS Image And File Upload Example." larainfo | Sciencx - Wednesday August 25, 2021, https://www.scien.cx/2021/08/25/tailwind-css-image-and-file-upload-example/
HARVARD
larainfo | Sciencx Wednesday August 25, 2021 » Tailwind CSS Image And File Upload Example., viewed ,<https://www.scien.cx/2021/08/25/tailwind-css-image-and-file-upload-example/>
VANCOUVER
larainfo | Sciencx - » Tailwind CSS Image And File Upload Example. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/08/25/tailwind-css-image-and-file-upload-example/
CHICAGO
" » Tailwind CSS Image And File Upload Example." larainfo | Sciencx - Accessed . https://www.scien.cx/2021/08/25/tailwind-css-image-and-file-upload-example/
IEEE
" » Tailwind CSS Image And File Upload Example." larainfo | Sciencx [Online]. Available: https://www.scien.cx/2021/08/25/tailwind-css-image-and-file-upload-example/. [Accessed: ]
rf:citation
» Tailwind CSS Image And File Upload Example | larainfo | Sciencx | https://www.scien.cx/2021/08/25/tailwind-css-image-and-file-upload-example/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.