Tailwind CSS Handbook v4.3

Borders

Border width, colour, style and radius — plus outlines, rings and dividers, and the default border colour change in v4.

Borders, outlines and rings are three different ways to draw a line around an element. Knowing which to use is most of the battle.

Width#

UtilityValue
border1px, all sides
border-0 border-2 border-4 border-8Explicit widths
border-x-2 / border-y-2Horizontal / vertical pairs
border-t border-r border-b border-lIndividual sides
border-s-2 / border-e-2Logical start / end
border-bs-2 / border-be-*Logical block start / end v4.2
border-[3px]Arbitrary

Default colour#

To restore the v3 default project-wide:

CSS
@layer base {
  *,
  ::after,
  ::before,
  ::backdrop,
  ::file-selector-button {
    border-color: var(--color-gray-200, currentColor);
  }
}

That said, being explicit is better — it makes dark mode obvious.

Colour and style#

HTML
<div class="border border-gray-200">Solid, 1px</div>
<div class="border-2 border-dashed border-indigo-500">Dashed</div>
<div class="border-t border-b border-gray-200">Top and bottom only</div>
<div class="border border-indigo-500/30">Translucent</div>
Style utilityCSS
border-solidDefault
border-dashed border-dotted border-doubleAlternatives
border-hidden border-noneNo border

Radius#

UtilityValue
rounded-none0
rounded-xs0.125rem
rounded-sm0.25rem
rounded-md0.375rem
rounded-lg0.5rem
rounded-xl0.75rem
rounded-2xl1rem
rounded-3xl1.5rem
rounded-full9999px

Per-corner and per-side#

HTML
<div class="rounded-t-xl">Top corners</div>
<div class="rounded-tl-xl rounded-br-xl">Diagonal corners</div>
<div class="rounded-s-lg">Logical start side</div>

Nested radii#

An inner element inside a padded rounded box needs a smaller radius to look right:

HTML
<div class="rounded-xl border border-gray-200 p-1">
  <div class="rounded-[calc(0.75rem-0.25rem)] bg-gray-100 p-4">…</div>
</div>

The formula is outer radius − padding. With theme variables:

HTML
<div class="rounded-[calc(var(--radius-xl)-4px)]">…</div>

Outline#

Outlines are drawn outside the border box and do not affect layout — which makes them ideal for focus indicators.

UtilityPurpose
outline / outline-2 / outline-4Width (also sets outline-style: solid)
outline-offset-2Gap between element and outline
outline-indigo-500Colour
outline-dashed outline-dottedStyle
outline-hiddenHide, but keep it in forced-colours mode
outline-noneoutline-style: none
Loading preview…

Rings#

A ring is a box-shadow shaped like an outline. Unlike a real outline it follows border-radius exactly.

UtilityPurpose
ring1px ring
ring-2 ring-4 ring-8Widths
ring-indigo-500Colour
ring-offset-2 ring-offset-whiteGap and its colour
ring-insetDraw inside the box
inset-ring-2Dedicated inset ring
Loading preview…

Border vs outline vs ring#

borderoutlinering
Affects layoutYes — adds to the boxNoNo
Follows border-radiusYesMostlyExactly
Can be per-sideYesNoNo
Best forStructure, dividersFocus indicatorsFocus rings, subtle elevation

Dividers#

divide-* puts borders between children, with none on the last one.

Loading preview…
UtilityPurpose
divide-y / divide-xDirection
divide-y-2Width
divide-gray-200Colour
divide-dashedStyle

Common patterns#

Card#

HTML
<div class="rounded-xl border border-gray-200 bg-white p-6 shadow-sm dark:border-gray-700 dark:bg-gray-800">…</div>

Input with a focus ring#

HTML
<input class="w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-indigo-500 focus:ring-2 focus:ring-indigo-500/20 focus:outline-none" />

Button group#

Loading preview…

Selected state without layout shift#

HTML
<label class="rounded-lg border border-gray-300 p-4 has-checked:border-indigo-500 has-checked:ring-1 has-checked:ring-indigo-500">
  <input type="radio" name="plan" class="accent-indigo-600" /> Pro
</label>

Common mistakes#

  • Relying on the v3 default border colour. border alone is currentColor in v4.
  • border-2 on hover. Causes a 1px layout jump. Use a ring, or set the border width in both states.
  • outline-none with no replacement. Breaks keyboard navigation. Use outline-hidden plus a visible ring.
  • Rounded parent without overflow-hidden. Child images poke through the corners.
  • Forgetting the dark-mode border. border-gray-200 glows on a dark surface.
  • Expecting divide-* to work on a flex container with gap. It works, but the gap and the divider fight; pick one.