Sub topic 10
One-off breakpoints with arbitrary values
Tailwind's default breakpoints cover most layouts. Sometimes a single element needs to change at a width the defaults don't offer, such as 900px or 1100px. Arbitrary breakpoint values let you write that width directly in the class name, without touching your theme.
This chapter assumes you know the mobile-first model, the default sm to 2xl prefixes, and how max-* variants work. It covers the min-[...] and max-[...] syntax, how it compares with the theme-based approach, and the mistakes that come with it.
What an arbitrary breakpoint is
Tailwind lets you put any value in square brackets to create a one-time utility or variant. For breakpoints, you place a width inside the min-[...] or max-[...] variants:
<div class="min-[900px]:flex max-[600px]:hidden">One-off breakpoints</div>Each variant maps to a media query:
| Class prefix | Media query it generates | Applies when |
|---|---|---|
| `min-[900px]:` | `@media (min-width: 900px)` | viewport is 900px or wider |
| `max-[600px]:` | `@media (max-width: 600px)` | viewport is 600px or narrower |
The min-[...] variant works like sm: or md:. The only difference is that you chose the number yourself. Tailwind generates the CSS for a bracket value only when it finds that exact class in your source files, so unused values cost nothing.
Choosing units
The value inside the brackets is ordinary CSS length syntax. You can use pixels, rem or em.
<aside class="hidden min-[56rem]:block">Sidebar</aside>The default breakpoints are defined in rem, so they scale with the user's font size. A min-[900px] breakpoint does not. If a user raises their browser's default font size, a rem-based breakpoint triggers at a larger pixel width, which tends to keep text from getting cramped. A pixel-based one stays fixed. For layouts that carry a lot of text, prefer rem so your one-off values behave like the built-in ones.
Mobile-first still applies
An arbitrary min-[...] variant follows the same mobile-first rule as the named ones. The unprefixed class applies at every width, and the bracketed variant overrides it from that width upward.
<div class="flex flex-col min-[900px]:flex-row">
<div class="p-4">Left</div>
<div class="p-4">Right</div>
</div>Below 900px the children stack. At 900px and above they sit in a row. This is the same pattern you used with md:flex-row, with a different threshold.
Mixing arbitrary and named breakpoints
You can use arbitrary values next to the default prefixes on one element. The CSS cascade decides which rule wins, and Tailwind sorts the generated media queries so that larger min-width values come later. For min-* variants, the order in your class attribute does not matter. The widest matching breakpoint wins.
<div class="grid grid-cols-1 md:grid-cols-2 min-[1100px]:grid-cols-4">
<div>A</div>
<div>B</div>
<div>C</div>
<div>D</div>
</div>With the default md at 768px, this layout has one column below 768px, two columns from 768px to 1099px, and four columns from 1100px. The arbitrary breakpoint slots between lg (1024px) and xl (1280px) without any configuration.
Building a range with arbitrary values
You can pair min-[...] and max-[...] to confine a style to a window of widths. The two variants stack the same way md:max-lg: does.
<p class="min-[700px]:max-[1000px]:text-center">
Centered only between 700px and 1000px
</p>This generates a rule that applies when the viewport is at least 700px and at most 1000px. Both ends are inclusive, because min-width and max-width include their boundary values.
You can also combine an arbitrary bound with a named one:
<div class="md:max-[1000px]:hidden">Hidden from 768px through 1000px</div>The named md: supplies the lower bound and the bracket supplies the upper.
Edge case: the off-by-one at boundaries
The named max-* variants, such as max-lg:, use an exclusive upper bound. The utility applies below 1024px, not at 1024px. An arbitrary max-[1024px]: is different. It applies at 1024px and below.
This leaves a one-pixel mismatch. At exactly 1024px, max-lg:hidden does not hide the element, but max-[1024px]:hidden does. In a layout that pairs a bracket value with a named variant, the two can both be active at the same width, or both be inactive. If you need a seamless handoff, pair min-[N] with the matching named variant rather than mixing a max-[N] with a min-* value of the same number.
<!-- At exactly 1024px, both of these are visible -->
<div class="lg:hidden">Mobile menu</div>
<div class="hidden max-[1024px]:block">Overlaps at 1024px</div>The first element hides from 1024px up. The second shows at 1024px and below. At exactly 1024px the first is hidden and the second is shown, so there is no overlap here. If you flip the pairing, the mismatch appears:
<!-- At exactly 1024px, both of these are visible -->
<div class="max-lg:hidden">Desktop menu</div>
<div class="hidden max-[1024px]:block">Mobile menu</div>The first element hides below 1024px, so it is visible at 1024px. The second also shows at 1024px. Both are on screen. Choose one convention for each pair of elements and keep both sides on it.
When to use an arbitrary breakpoint
Arbitrary values suit a narrow set of situations.
- A single component has a layout problem at one specific width, and no other part of the site shares it.
- You are prototyping and don't yet know the final values.
- A design handed over by a designer uses a width that appears once.
They are a poor fit when the same number appears in many places.
<!-- Repeating the same magic number is fragile -->
<div class="min-[900px]:flex">A</div>
<div class="min-[900px]:grid">B</div>
<div class="min-[900px]:p-8">C</div>If you change your mind about 900px, you have to find and edit every occurrence, and a typo such as min-[990px] silently creates a different breakpoint. Once a value appears in three or four places, promote it to a theme breakpoint. In Tailwind v4 that is one line:
@import "tailwindcss";
@theme {
--breakpoint-3xl: 120rem;
}In v3 you add it under theme.extend.screens:
/** @type {import('tailwindcss').Config} */
module.exports = {
theme: {
extend: {
screens: {
'3xl': '1920px',
},
},
},
};You can then write 3xl: everywhere and change the number in one place.
Arbitrary breakpoints versus container queries
An arbitrary breakpoint still measures the viewport. If your real problem is that a card changes layout depending on the space it is given, not on the window width, no viewport value will fix it reliably. The same card in a narrow sidebar and a wide main column needs different layouts at the same viewport width. For that case, use container queries, which respond to the parent's width:
<div class="@container">
<div class="grid grid-cols-1 @md:grid-cols-2">
<div>Card</div>
<div>Card</div>
</div>
</div>Tailwind v4 also supports arbitrary container sizes with the same bracket idea, for example @min-[400px]:. Reach for this when a component must be reusable in different places.
Common mistakes
- Spaces inside the brackets. Tailwind reads class names split on whitespace, so
min-[900px ]:flexis not valid. Write the value without spaces. - Missing units.
min-[900]:flexgenerates no usable query, because900is not a length. Always includepx,remorem. - Building class names dynamically. A string like `
min-[${width}px]:flex` is never seen by Tailwind's scanner, so the CSS is not generated. Write the full class name in your source, or choose from a fixed set of complete class strings. - Forgetting the viewport meta tag. Arbitrary breakpoints depend on the real device width just like named ones. Without
<meta name="viewport" content="width=device-width, initial-scale=1">, mobile browsers report a wide virtual viewport and yourmax-[600px]styles never apply. - Using brackets where a named step exists.
min-[768px]:duplicatesmd:and hides your intent. Use the named variant when it matches.
Summary of the decision
| Situation | Use |
|---|---|
| Width matches a default step | `sm:`, `md:`, `lg:`, `xl:`, `2xl:` |
| One element, one unusual width | `min-[...]:` or `max-[...]:` |
| Same width used in several places | A theme breakpoint (`--breakpoint-*` or `screens`) |
| Layout depends on parent size | Container query (`@container`, `@md:`) |
Exercise
A card grid should show one column by default, three columns from 1100px wide, and hide a promotional banner only between 700px and 1000px (inclusive). Write the class lists for the grid and for the banner.
Show answer
Grid: grid grid-cols-1 min-[1100px]:grid-cols-3. Banner: min-[700px]:max-[1000px]:hidden. The unprefixed grid-cols-1 applies at every width, the min-[1100px] variant overrides it from 1100px upward, and the stacked min- and max- variants confine hidden to the 700px to 1000px window.
Exercise
A page uses max-lg:hidden on a desktop menu and hidden max-[1024px]:block on a mobile menu. What does the viewport show at exactly 1024px, and how would you fix it?
Show answer
Both menus are visible at exactly 1024px. max-lg: is exclusive, so it hides the desktop menu only below 1024px, while max-[1024px]: includes 1024px, so the mobile menu also shows. Fix it by pairing a named variant with a named variant, for example hidden lg:block for the desktop menu and lg:hidden for the mobile menu.
Exercise
Your code builds the class string min-[${n}px]:flex from a variable n. The layout never changes. Why, and what is a safe alternative?
Show answer
Tailwind scans source files as plain text and never sees the finished class name, so it generates no CSS for it. Write complete class names, such as min-[900px]:flex and min-[1100px]:flex, and select between those full strings in your code.