Discover how custom breakpoints save you hours of frustrating CSS rewriting!
Why Custom breakpoints in Tailwind? - Purpose & Use Cases
Imagine you want your website to look good on all devices, from tiny phones to huge screens. You try to write CSS rules for each screen size by guessing widths and writing many media queries.
Writing many media queries by hand is slow and confusing. If you want to change a breakpoint, you must find and update every media query. It's easy to make mistakes and hard to keep consistent.
Custom breakpoints in Tailwind let you define your own screen sizes once. Then you use simple class names that automatically apply styles at those sizes. This keeps your code clean and easy to update.
@media (min-width: 640px) { .text { font-size: 1.25rem; } } @media (min-width: 768px) { .text { font-size: 1.5rem; } }
// tailwind.config.js
module.exports = {
theme: {
extend: {
screens: {
'tablet': '640px',
'laptop': '1024px',
},
},
},
}
// usage in HTML
<div class="tablet:text-lg laptop:text-xl">Text</div>You can easily design responsive layouts that adapt perfectly to your own device sizes without messy CSS.
A company wants their site to look great on their specific product displays and custom devices, so they create breakpoints matching those exact screen widths.
Manual media queries are hard to manage and update.
Custom breakpoints let you define screen sizes once in Tailwind.
Use simple classes to apply styles at your chosen breakpoints easily.