Tailwind Drop Shadow

Here we discuss Tailwind Drop Shadow, how to apply it, and how it can make your website more appealing to the eye.

Tailwind Drop Shadow enables you to add shadows to elements.

Tailwind Drop Shadow

By default, drop shadows have a color of black and a blur radius of 1px. However, you can adjust the color, size, and spread of the shadow to suit your preferences.

In traditional CSS, we can achieve this by using the CSS drop-shadow() function.

Tailwind CSS added this feature in version 2.1.

Syntax

<element class="filter drop-shadow-{amount}">...</element>

You can use the following code to add a drop shadow that is red, has a blur radius of 4px, and has a spread of 2px

<element class="drop-shadow-red-lg">Mr Examples</element>
This will add a drop shadow with a red color, a blur radius of 4 pixels, and a spread of 2 pixels to the element.


Tailwind Drop Shadow Classes

ClassesOverview
drop-shadow-smThis class is intended for applying a small shadow effect.
drop-shadowA normal shadow effect is applied using this class.
drop-shadow-mdThis class sets a medium shadow effect on an element.
drop-shadow-lgThis class results in a large shadow effect on an element.
drop-shadow-xlUsing this class, you can set an extra-large shadow effect.
drop-shadow-2xlThis class is used to apply a double extra large shadow effect on an element.
drop-shadow-noneShadow effects are removed after the use of this class.

In below example, we will explore the drop shadow class in Tailwind using drop-shadow-none, drop-shadow-lg and drop-shadow-2xl classes:

Example: 

<!DOCTYPE html> <html> <head> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="text-center mx-4 space-y-2"> <h1 class="text-gray-600 text-2xl font-semibold"> MrExamples </h1> <p class="font-semibold my-2">Drop Shadow Class in Tailwind CSS</p> <div class="grid grid-cols-2 gap-2 text-center p-4"> <div class="flex flex-col justify-center items-center"> <p class="font-medium text-gray-600">drop-shadow-none</p> <img class="rounded-lg w-28 border drop-shadow-none" src="https://mrexamples.com/wp-content/uploads/2023/02/tailwind2.jpg" alt="image"> </div> <div class="flex flex-col justify-center items-center"> <p class="font-medium text-gray-600">drop-shadow</p> <img class="rounded-lg w-28 border drop-shadow" src="https://mrexamples.com/wp-content/uploads/2023/02/tailwind2.jpg" alt="image"> </div> <div class="flex flex-col justify-center items-center"> <p class="font-medium text-gray-600">drop-shadow-lg</p> <img class="rounded-lg w-28 border drop-shadow-lg" src="https://mrexamples.com/wp-content/uploads/2023/02/tailwind2.jpg" alt="image"> </div> <div class="flex flex-col justify-center items-center"> <p class="font-medium text-gray-600">drop-shadow-2xl</p> <img class="rounded-lg w-28 border drop-shadow-2xl" src="https://mrexamples.com/wp-content/uploads/2023/02/tailwind2.jpg" alt="image"> </div> </div> </body> </html>

The below example is a practical demonstration of the drop-shadow class in Tailwind using drop-shadow-sm, drop-shadow-md and drop-shadow-xl:

Example: 

<!DOCTYPE html> <html> <head> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="text-center mx-4 space-y-2"> <h1 class="text-gray-600 text-2xl font-semibold"> MrExamples </h1> <p class="font-semibold my-2">Drop Shadow Class in Tailwind CSS</p> <div class="grid grid-cols-2 gap-2 text-center p-4"> <div class="flex flex-col justify-center items-center"> <p class="font-medium text-gray-600">drop-shadow-sm</p> <img class="rounded-lg w-28 border drop-shadow-sm" src="https://mrexamples.com/wp-content/uploads/2023/02/tailwind2.jpg" alt="image"> </div> <div class="flex flex-col justify-center items-center"> <p class="font-medium text-gray-600">drop-shadow-md</p> <img class="rounded-lg w-28 border drop-shadow-md" src="https://mrexamples.com/wp-content/uploads/2023/02/tailwind2.jpg" alt="image"> </div> <div class="flex flex-col justify-center items-center"> <p class="font-medium text-gray-600">drop-shadow-xl</p> <img class="rounded-lg w-28 border drop-shadow-xl" src="https://mrexamples.com/wp-content/uploads/2023/02/tailwind2.jpg" alt="image"> </div> </div> </body> </html>

We value your feedback.
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!
icon

Leave a Reply

Your email address will not be published. Required fields are marked *