Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 649

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

$
0
0

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 all articles
Browse latest Browse all 649

Trending Articles



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