Here are two steps to follow in order to hide a scrollbar in your HTML elements using TailwindCSS.
Step I
Go to your global.css file styles/global.css and past this code:
/* global index.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
/* add the code bellow */
@layer utilities {
/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
}
At this point we added
::-webkit-scrollbarto target the scrollbar style inChrome,Safari,EdgeandOpera.
no-scrollbar is the class that we are going to use for hidding the scrollbar.
Step II
Now use no-scrollbar to hide the scrollbar in your elements. Like this:
<div className="w-full h-42 overflow-y-scroll no-scrollbar">...</div>
I hope you find this post useful.
Feel free to connect with me on X


Latest comments (42)
Thank you π
must add overflow-auto**
can you elaborate
thanks
Great. Works like a charm.
Combine the author's above, global scrollbar was hidden π
Nice one π―
Thank you, That worked for me
thanks for your work it helps me a lot. thanks once again
Glad its helped!
How should I make scrollbar visible in desktop and hidden in mobile?
I don't know but try this and let me know if it works:
in your
global.cssadd this code:Now, use the scrollbar class in combination with the
lg(large screen) prefix from Tailwind to make the scrollbar visible only on desktop:am the witness: it works
that's pretty cool
It works!!
Thankyou bro
Glad its helped!
thanks boss , please how did you get this **comment **text box
Some comments have been hidden by the post's author - find out more