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


Top comments (42)
Great share, Derick. This really helped me π«‘
BTW, if you're using TailwindCSS v3.0 or higher, you should remove:
else you'll get this warning in terminal:
I've already updated the code based on your suggestion, Nice Catch
you win chatgpt4 for this problem
Thank you so much for your kind words!
Thanks for sharing.
Btw
scrollbar-width: none;didn't work for me.But using
scrollbar-width: 0;worked.thanks this help me alot
Your are welcome
Great! Thank you.
Niceππ
Thank you
thank you!
I'm glad it helped
Amazing Derick. You solved my problem.
Combine the author's above, global scrollbar was hidden π
Nice one π―
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
Some comments have been hidden by the post's author - find out more