Typi non habent claritatem insitam est usus legentis in iis qui facit eorum claritatem. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Therefore, a scrollbar is added to help the reader to scroll the content. That’s it for this one! I hope you learned how to hide scrollbars using Tailwind CSS and how arbitrary variants can help you create a more robust solution depending on your use case.This text is really long and the height of its container is only 100 pixels. And check this to learn more about arbitrary variants. Going back again to our original example, we can modify it by using an arbitrary variant like this: Ĭheck this Tailwind Play link for a demo. Note: The overflow property only works for block elements with a specified height. This property specifies whether to clip content or to add scrollbars when an elements content is too big to fit in a specified area. ⭐ Keep in mind you have to be using Tailwind CSS’ 3.1 version or higher for this to work. Definition and Usage The overflow property specifies what should happen if content overflows an elements box. Now, I know this does the job but I find it a bit excessive since you’re changing the behavior of a very common breakpoint and you’re probably only using that class in a handful of places.Īfter doing some research I found we can also use the new arbitrary variant feature for this! Here’s how to do the first recommendation, in the tailwind config: // This is an issue documented by the plugin’s author and his recommendation is to change the breakpoint to be desktop-first instead of mobile-first or remove the class with Javascript. This doesn’t work in Chrome and Safari, and it's not the plugin’s fault, it’s how the scrollbar works in WebKit browsers, mainly this: ::-webkit-scrollbar cannot be simply overridden to get the default style, the only way to do it is to remove all ::-webkit-scrollbar rules from the code. ⭐ Remember that the scrollbar-hide and scrollbar-default classes come from the plugin, these classes don’t exist on Tailwind itself. Using our original example, let’s say you want to show the scrollbar, on bigger breakpoints, like this: This CSS solution is optimal but there’s actually one big issue, in WebKit-based browsers (Chrome, Safari, and Opera) you cannot override the class, you can only remove it. Sounds easy enough, right? There’s one catch Now you can use the scrollbar-hide class, without writing any custom CSS □. Then on your, you add the package on your plugins array: // On your terminal npm install tailwind-scrollbar-hide Using our previous example and plugin #1, here's how it would work: Install the plugin I like the first one better because it has better docs and examples but you can pick whichever you prefer. Well, there are actually 2, but both do the same thing: scrollbar-hide class on an overflowing container to hide the scrollbar, here’s an example using Tailwind’s utility classes: īut if you’re a tailwind lover, like me, instead of creating a custom CSS declaration you probably want a more tailwind-centric approach. ms- overflow-style: none /* IE and Edge */ Scrollbars are visual indicators we’re all used to when browsing the web but for us developers, sometimes we just don’t want to show them.īrowser compatibility for hiding them has evolved a lot over the years but right now you need at least 2 CSS declarations to do it ( thanks StackOverflow): /* For Webkit-based browsers (Chrome, Safari and Opera) */
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |