Quantcast
Viewing latest article 2
Browse Latest Browse All 644

How to make a header in react have a shadow only on scroll using tailwindcss?

I have a header in react that I want to have no shadow when the scrollbar position is initial (0), and on scroll, to have a shadow. Here is the code to the header with and without a shadow using tailwindCSS:

With shadow:

<header className="sticky left-0 top-0 right-0 z-20 shadow">...</header>

Without shadow:

<header className="sticky left-0 top-0 right-0 z-20">...</header>

How can I check if the scrollbar is not in its initial position to make the header take the className "shadow"?


Viewing latest article 2
Browse Latest Browse All 644

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>