Sub topic 6
Rounding corners
Tailwind CSS rounds corners with the rounded family of utilities, which set the CSS border-radius property. This chapter covers the size scale, per-side and per-corner control, the behavior that causes most bugs (clipping, nesting, and interaction with borders and rings), and how to pick a radius. It assumes you know the box model and the utility-class idea, and that you have already used border width and color utilities from the previous chapters.
The radius scale
A radius is the size of the circle used to round a corner. A bigger value gives a rounder corner. Tailwind provides a named scale so that radii stay consistent across a project.
| Utility (v3) | Utility (v4) | Value |
|---|---|---|
| `rounded-none` | `rounded-none` | 0 |
| `rounded-sm` | `rounded-xs` | 0.125rem (2px) |
| `rounded` | `rounded-sm` | 0.25rem (4px) |
| `rounded-md` | `rounded-md` | 0.375rem (6px) |
| `rounded-lg` | `rounded-lg` | 0.5rem (8px) |
| `rounded-xl` | `rounded-xl` | 0.75rem (12px) |
| `rounded-2xl` | `rounded-2xl` | 1rem (16px) |
| `rounded-3xl` | `rounded-3xl` | 1.5rem (24px) |
| `rounded-full` | `rounded-full` | effectively infinite |
Tailwind v4 shifted the two smallest names down one step, and added rounded-4xl (2rem). Version 3 projects that are upgraded to version 4 therefore need rounded renamed to rounded-sm, and rounded-sm renamed to rounded-xs. If you copy snippets between projects, check which version each one targets.
<div class="flex flex-wrap items-center gap-4 p-6">
<div class="h-16 w-16 rounded-none bg-indigo-600"></div>
<div class="h-16 w-16 rounded-md bg-indigo-600"></div>
<div class="h-16 w-16 rounded-xl bg-indigo-600"></div>
<div class="h-16 w-16 rounded-3xl bg-indigo-600"></div>
<div class="h-16 w-16 rounded-full bg-indigo-600"></div>
</div>The five squares show the range from sharp corners to a circle. On a square, rounded-full produces a circle. On a rectangle it produces a pill, because the radius is capped at half of the shorter side.
Rounding individual sides and corners
You can round one side (two corners) or one corner by adding a position suffix.
| Suffix | Corners affected |
|---|---|
| `t`, `r`, `b`, `l` | The two corners on the top, right, bottom, or left side |
| `tl`, `tr`, `br`, `bl` | One physical corner |
| `s`, `e` | Start or end side, which follows text direction |
| `ss`, `se`, `ee`, `es` | One logical corner |
For example, rounded-t-xl rounds the top two corners and rounded-br-3xl rounds only the bottom-right corner. The suffix goes before the size: rounded-t-lg, not rounded-lg-t.
<div class="w-72 overflow-hidden rounded-xl border border-slate-200 bg-white">
<div class="rounded-t-xl bg-indigo-600 p-3 text-white">Header</div>
<div class="p-4 text-slate-700">Body text under a rounded header.</div>
</div>The logical variants (rounded-s-*, rounded-e-*) matter for right-to-left languages. With dir="rtl", rounded-s-lg rounds the right side, so a button group mirrors itself without extra classes. Use physical names when the shape must not flip.
Segmented groups
A row of joined buttons needs rounded outer corners and square inner ones. Round only the ends:
<div class="inline-flex">
<button class="rounded-l-md border border-slate-300 bg-white px-3 py-1.5">Day</button>
<button class="-ml-px border border-slate-300 bg-white px-3 py-1.5">Week</button>
<button class="-ml-px rounded-r-md border border-slate-300 bg-white px-3 py-1.5">Month</button>
</div>The -ml-px class pulls each button over the previous one so the shared border is 1px, not 2px.
What the radius actually clips
Border radius changes the shape of the element's own box. It affects the background, the border, and box shadows and rings drawn outside it. It does not automatically clip children. A child with a square background pokes out through the rounded corner.
<div class="w-64 rounded-2xl border border-slate-200 bg-white">
<img class="h-32 w-full object-cover" src="photo.jpg" alt="Mountain lake" />
<p class="p-4">Image corners stick out.</p>
</div>In this snippet the image's square corners cover the card's rounded border. There are two fixes:
- Add
overflow-hiddento the parent, which clips everything to the rounded shape. - Round the child itself with
rounded-t-2xl.
The first is simpler. It has a cost: overflow-hidden also clips anything meant to escape the card, such as a dropdown menu or an outside focus ring on a child. When a card contains such elements, prefer rounding the children directly.
<div class="w-64 overflow-hidden rounded-2xl border border-slate-200 bg-white">
<img class="h-32 w-full object-cover" src="photo.jpg" alt="Mountain lake" />
<p class="p-4">Image corners are clipped.</p>
</div>The same rule applies to divide-y lists with a border. The list items are square, so add overflow-hidden to the <ul> if their backgrounds change on hover.
Borders, rings, and shadows follow the curve
Borders, ring-* utilities, and shadow-* utilities all follow the element's radius. Rounding an input with rounded-md also rounds its focus ring, with no extra classes.
<input
type="text"
class="rounded-lg border border-slate-300 px-3 py-2 focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500"
/>Per-side border colors need care on curves. If you set border-b-emerald-500 on a rounded box, the color blends diagonally through each curved corner, with the bottom color fading into the other sides. This is how browsers draw it, not a Tailwind quirk. For a clean accent line, a common alternative is to put the accent on a separate child element.
Nesting radii
When a rounded element sits inside another with padding, the two radii should be concentric. The rule is:
> inner radius = outer radius − padding
An outer rounded-2xl (1rem) with p-2 (0.5rem) of padding calls for an inner radius of 0.5rem, which is rounded-lg.
<div class="rounded-2xl bg-slate-200 p-2">
<div class="rounded-lg bg-white p-4">Concentric corners</div>
</div>If you used the same radius on both, the gap between the two curves would look thicker at the corners than along the edges. If the padding is larger than the outer radius, the inner element can stay square-looking, so use a small radius or none.
Arbitrary and custom values
Use square brackets for a radius outside the scale, for example rounded-[10px] or rounded-t-[2rem]. Arbitrary values work for any side.
For a value you reuse, add it to the theme. In v4:
@import "tailwindcss";
@theme {
--radius-card: 1.25rem;
}This generates rounded-card, as well as side variants like rounded-t-card. In v3 the equivalent is theme.extend.borderRadius.card in tailwind.config.js.
An elliptical corner (different horizontal and vertical radii) is not part of the scale. Write it as an arbitrary value, such as rounded-[50%/20%].
Choosing a radius
Some practical defaults: rounded-md for buttons and inputs, rounded-xl for cards, and rounded-full for avatars and badges. What matters most is using the same few sizes everywhere. Mixing rounded-lg, rounded-[7px], and rounded-xl on one screen looks accidental.
Common errors
- Square corners on images or colored children. The parent is rounded but not clipping. Add
overflow-hiddenor round the child. rounded-fullon a rectangle gives a pill, not a circle. Give the element equal width and height for a circle.- Copied v3 classes look different in v4.
roundedandrounded-smmoved down one step. - Side utilities do nothing visible. A later class such as
rounded-lgcan override an earlierrounded-t-none, depending on generated CSS order, so avoid mixing a full radius with side overrides on the same element. - Dropdown or ring cut off. An ancestor with
overflow-hiddenclips it.
Exercise
A card uses rounded-3xl p-3 and contains an inner panel. Which radius from the scale gives concentric corners for the panel, and why? (3xl = 1.5rem, p-3 = 0.75rem.)
Show answer
The inner radius is 1.5rem − 0.75rem = 0.75rem, which is rounded-xl. Using the outer radius minus the padding keeps the gap between the two curves even around the corner.
Exercise
You build a card with rounded-xl and place a full-width <img> at the top. The image corners stick out past the card's curve. Name two ways to fix this and one downside of the first.
Show answer
Add overflow-hidden to the card, or add rounded-t-xl to the image. The downside of overflow-hidden is that it clips anything that should extend outside the card, such as dropdown menus or outside focus rings on children.