Skip to content

Blog

Tailwind breakpoints in px, and how to change them (v4)

Frank Spin7 min read

Tailwind CSS v4 has five breakpoints: sm at 640px, md at 768px, lg at 1024px, xl at 1280px and 2xl at 1536px. This page lists them with their real values, shows how mobile-first prefixes, max-* and ranges like md:max-xl: work, how to add or remove a breakpoint in v4's CSS config, what the container class does now (less than in v3), and when a container query is the better tool.

Every class here was compiled with Tailwind 4.3.3 and the CSS shown is its output.

The default breakpoints#

PrefixMin widthIn remCSS
sm:640px40rem@media (width >= 40rem)
md:768px48rem@media (width >= 48rem)
lg:1024px64rem@media (width >= 64rem)
xl:1280px80rem@media (width >= 80rem)
2xl:1536px96rem@media (width >= 96rem)

v4 defines them in rem (v3 used px), so they move with the reader's browser font size. With a 20px default font size set in the browser, md: starts at 960px instead of 768px. That's usually a feature: a reader who needs larger text gets the roomier small-screen layout sooner.

Mobile first: what md: actually means#

A class without a prefix applies at every width. A prefixed class applies from that width up. So you write the phone layout first and add changes for wider screens:

<div class="grid grid-cols-1 gap-6 md:grid-cols-2 xl:grid-cols-3">…</div>

One column on phones, two from 768px, three from 1280px. The mistake everyone makes once is sm:grid-cols-1 to target phones. sm: means "640px and wider"; phones below 640px get the unprefixed class. There is no xs: by default; the unprefixed class is the smallest breakpoint.

Below a breakpoint and between two#

Every breakpoint also has a max-* variant that applies below it, and you can stack the two for a range:

ClassApplies whenCSS
max-md:hiddennarrower than 768px@media (width < 48rem)
md:max-xl:flex768px up to 1279px@media (width >= 48rem) { @media (width < 80rem) }
min-[900px]:flex900px and wider@media (width >= 900px)
max-[600px]:flexnarrower than 600px@media (width < 600px)

Use max-* sparingly. A layout built mobile-first with md: and lg: is easier to follow than one that switches things off going down. Where it earns its place: hiding a desktop-only element on phones (max-md:hidden), or a tablet-only tweak with a range.

Show the current breakpoint while you work#

A small fixed badge that names the active breakpoint saves a lot of resizing and guessing. Put it in your layout during development:

<div class="fixed right-2 bottom-2 z-50 rounded bg-black px-2 py-1 font-mono text-xs text-white">
  <span class="sm:hidden">base</span>
  <span class="hidden sm:inline md:hidden">sm</span>
  <span class="hidden md:inline lg:hidden">md</span>
  <span class="hidden lg:inline xl:hidden">lg</span>
  <span class="hidden xl:inline 2xl:hidden">xl</span>
  <span class="hidden 2xl:inline">2xl</span>
</div>

Add, change or remove breakpoints in v4#

v4 has no screens key in a JavaScript config. Breakpoints are theme variables named --breakpoint-*, set in your CSS:

@import "tailwindcss";

@theme {
  --breakpoint-xs: 30rem;     /* adds xs: at 480px */
  --breakpoint-3xl: 120rem;   /* adds 3xl: at 1920px */
  --breakpoint-2xl: initial;  /* removes 2xl: */
}

Tailwind sorts breakpoints by value, so xs: lands before sm: in the CSS without any extra work. Keep them in the same unit (all rem or all px), because values in different units can't be sorted reliably. To start from scratch, reset the whole namespace first with --breakpoint-*: initial; and then define your own.

If you're moving a v3 screens object over, our Tailwind config to v4 converter turns it into the @theme block.

The container class in v4#

container sets width: 100% and a max-width equal to the current breakpoint. That's all. Compiled:

.container {
  width: 100%;
  @media (width >= 40rem) { max-width: 40rem; }
  @media (width >= 48rem) { max-width: 48rem; }
  @media (width >= 64rem) { max-width: 64rem; }
  @media (width >= 80rem) { max-width: 80rem; }
  @media (width >= 96rem) { max-width: 96rem; }
}

It doesn't center itself and has no side padding, and v4 dropped the v3 config options center and padding. To get them back, extend the utility in your CSS:

@utility container {
  margin-inline: auto;
  padding-inline: 1rem;
}

The container follows your breakpoints, including ones you add or remove. Many sites don't need it at all: mx-auto max-w-6xl px-6 gives one fixed maximum width, which is what most layouts want. The width jumping at every breakpoint is the container behaviour people often don't expect. All the footer and header examples in our footer guide use max-w-6xl for that reason.

Container queries: breakpoints for components#

Breakpoints respond to the window. A card in a sidebar and the same card in a wide main column see the same window width but have very different space. Container queries, built into v4 (they were a plugin in v3), respond to the parent instead:

<div class="@container">
  <article class="flex flex-col gap-4 @md:flex-row">…</article>
</div>

The article goes side by side once its container is 28rem (448px) wide, wherever the card is placed. Container sizes are a separate scale from the breakpoints:

VariantMin container width
@3xs:16rem (256px)
@2xs:18rem (288px)
@xs:20rem (320px)
@sm:24rem (384px)
@md:28rem (448px)
@lg:32rem (512px)
@xl:36rem (576px)
@2xl:42rem (672px)
@3xl:48rem (768px)
@4xl: to @7xl:56rem to 80rem

@max-md: works below a size, @min-[500px]: takes any value, and you can name containers when they're nested: @container/main on the parent and @md/main:flex on the child.

Our rule of thumb: page layout (columns, the header switching to a menu button) uses breakpoints; anything that can appear in more than one place (cards, pricing tables, form rows) uses container queries. A component built with breakpoints only looks right at the width you tested it in; one built with container queries can be dropped into a sidebar without a second version.

FAQ#

What are the Tailwind breakpoints in px?

sm 640px, md 768px, lg 1024px, xl 1280px, 2xl 1536px. In v4 they're defined in rem (40, 48, 64, 80 and 96rem), which equals those pixel values at the default 16px font size.

How do I target only mobile in Tailwind?

Write the class without a prefix and override it from a breakpoint up: flex md:hidden shows on phones and hides from 768px. For a one-off, max-md: applies only below 768px.

How do I add a custom breakpoint in Tailwind v4?

Add a theme variable in your CSS: @theme { --breakpoint-xs: 30rem; }. That creates xs: and max-xs:. For a single use, min-[480px]: works without any config.

Why doesn't container center my content in v4?

Because v4's container only sets the width and max-width. Add mx-auto px-4 to the element, or extend the utility once with @utility container { margin-inline: auto; padding-inline: 1rem; }.

Built on Tailwind CSS v4

1401 finished blocks on shadcn/ui, React and Astro

UI Pro, from €199

Build it with

Preview

Open the page
In UI Pro: get it, €199 once

With every block and theme. 400+ buyers since 2020. Plans

UI Pro

Build your next site from finished blocks

Every block, page template and website theme from €199, paid once, with every update and everything we add later. Not ready? The free blocks are open to everyone.

blocks
1401
page templates
55
website themes
29
The Case study page template from UI Pro, built from its blocks.

This page is built from UI Pro blocks: Zandloper (article-14), Rooilijn (call-to-action-07).