How to Add a Drop Shadow to a PNG Image

Updated: May 16, 2022 By: Pennywise Post a comment

In Tailwind CSS, you can add a drop shadow to a PNG image (the shadow will depend on the shape of the PNG’s content) by using one of the following utility classes:

  • drop-shadow-sm
  • drop-shadow
  • drop-shadow-md
  • drop-shadow-lg
  • drop-shadow-xl
  • drop-shadow-2xl

Example

In this example, the image on the left has a drop shadow and the image on the right does not:

The code:

<body>
    <div class="flex space-x-8 p-20">
        <!-- drop shadow -->
        <img class="w-96 h-72 object-contain drop-shadow-2xl shadow-black"
            src="https://www.kindacode.com/wp-content/uploads/2022/05/water-melon.png" />

        <!-- no shadow -->
        <img class="w-96 h-72 object-contain"
            src="https://www.kindacode.com/wp-content/uploads/2022/05/water-melon.png" />
    </div>
</body>

The image used in the example is from Pixabay, a famous website that provides free and beautiful images.

Further reading:

You can also check out our CSS category page for the latest tutorials and examples.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Related Articles