When I was writing a responsive template using TailwindCSS, I felt that it is not easy to know which breakpoint is active.
So I made a simple component that visualizes which breakpoint is active. The following snippet is the implementation of the component:
<div class="fixed top-0 right-0 m-8 p-3 text-xs font-mono text-white h-6 w-6 rounded-full flex items-center justify-center bg-gray-700 sm:bg-pink-500 md:bg-orange-500 lg:bg-green-500 xl:bg-blue-500">
<div class="block sm:hidden md:hidden lg:hidden xl:hidden">al</div>
<div class="hidden sm:block md:hidden lg:hidden xl:hidden">sm</div>
<div class="hidden sm:hidden md:block lg:hidden xl:hidden">md</div>
<div class="hidden sm:hidden md:hidden lg:block xl:hidden">lg</div>
<div class="hidden sm:hidden md:hidden lg:hidden xl:block">xl</div>
</div>
Copying this and pasting to your TailwindCSS template, you will see the indicator of the breakpoint on top right in your browser.
Also, you can check the live demo at CodePen.
See the Pen Tailwind CSS Responsive Active Breakpoint Indicator by suin (@suin) on CodePen.
Top comments (4)
updated to include 2xl support:
I used this so many times now. Just wanted to leave you a big thank you. It's easy to write this, but it's even easier to just google
tailwind breakpoints
every time I need this. :)mine shows only "al" at all sizes, do you know what's wrong?
nevermind i found the answer, my page was zoomed