A Tailwind border colour class has no visible effect
Fix it fast
Most common cause, 1 of 3Only a colour class is set, with no border width
Add a width utility next to the colour. border gives 1px; border-2, border-4 and the side variants such as border-b work the same way.
<div className="rounded-lg border border-red-500 p-4">
Payment failed
</div>Short answer
A Tailwind class such as border-red-500 sets only border-color, and Preflight resets every element's border to 0 width, so on its own it draws nothing; add border or border-2. A colour built with string interpolation is never generated. Since Tailwind v4 a bare border uses currentColor instead of v3's gray-200. Applies to Tailwind CSS 4.3.
Which cause do you have?
Print the element's computed border values in the browser console, with #card replaced by a selector for your element. A width of 0px means no width class applies; a set width with the text colour means the colour class never reached the stylesheet or was never written.
const el = document.querySelector('#card');
const cs = getComputedStyle(el);
console.log(cs.borderTopWidth, cs.borderTopStyle, cs.borderTopColor, cs.color);Then find the line you see in this list and open its fix:
- 1Only a colour class is set, with no border width
The console prints 0px for borderTopWidth even though border-red-500 is on the element - 2The colour class name is assembled at runtime
The markup builds the class with a template string, such as border-${color}-500, and the width is fine but the colour falls back to currentColor - 3v4 draws a bare border in currentColor, not v3's gray
After the upgrade to v4, elements with only the border class show a dark border in the text colour
What does the error look like?
border-red-500 is on the element but no border appearsThe border shows in the text colour instead of the colour set in the classBorders turned dark after upgrading from Tailwind v3 to v4
Cause 1 of 3
Only a colour class is set, with no border width
You seeThe console prints 0px for borderTopWidth even though border-red-500 is on the element
Check
A Tailwind border colour class seems not to work when the element has no width class. border-red-500 writes border-color and nothing else, and Preflight starts every element at border: 0 solid, so the colour is applied to a border that is zero pixels wide.
grep -rnE "border-[a-z]+-[0-9]{2,3}" app components src 2>/dev/nullFix
Add a width utility next to the colour. border gives 1px; border-2, border-4 and the side variants such as border-b work the same way.
<div className="rounded-lg border border-red-500 p-4">
Payment failed
</div>Verify
The console now prints 1px solid and the red value for the element's top border.
console.log(getComputedStyle(document.querySelector('#card')).borderTopWidth)Confirmed by tailwindcss.com
Cause 2 of 3
The colour class name is assembled at runtime
You seeThe markup builds the class with a template string, such as border-${color}-500, and the width is fine but the colour falls back to currentColor
Check
Tailwind generates a border colour only for class names that appear whole somewhere in your source files. It reads those files as plain text, so it cannot work out what border-${color}-500 turns into, and the finished class has no CSS behind it.
grep -rnE "border-\$\{" app components src 2>/dev/nullFix
Map each prop value to a complete class string, so every variant appears in the source as written. If a class truly cannot appear in source, force it with @source inline() in the CSS entry file.
const borderByStatus = {
error: 'border-red-500',
ok: 'border-green-600',
};
export function Card({ status, children }) {
return <div className={`border ${borderByStatus[status]}`}>{children}</div>;
}
/* app/globals.css, only for classes that never appear in source */
@import "tailwindcss";
@source inline("border-amber-500");Verify
Rebuild, reload the page and confirm the computed border colour matches the status.
npm run devConfirmed by tailwindcss.com
Cause 3 of 3
v4 draws a bare border in currentColor, not v3's gray
You seeAfter the upgrade to v4, elements with only the border class show a dark border in the text colour
Check
A border colour that changed after moving to Tailwind v4 comes from a changed default: v3 coloured border and divide utilities gray-200 when no colour class was given, while v4 uses currentColor to match the browser. A tailwind.config.js is also no longer read unless the CSS loads it with @config, so a default colour set there stops applying.
grep -rn "@config\|@import \"tailwindcss\"" app src --include="*.css" 2>/dev/nullFix
Name a colour wherever border or divide is used, or restore the v3 default once in the base layer, as the upgrade guide shows.
/* app/globals.css */
@import "tailwindcss";
@layer base {
*,
::after,
::before,
::backdrop,
::file-selector-button {
border-color: var(--color-gray-200, currentColor);
}
}Verify
Elements with only the border class show the light gray border again.
console.log(getComputedStyle(document.querySelector('#card')).borderTopColor)Confirmed by tailwindcss.com
How do I stop it coming back?
- Write border and its colour as a pair (border border-gray-200) in shared components, so neither depends on a default.
- Keep status-to-class maps in one file with every class spelled out in full, instead of building names from variables.
- Read the v4 upgrade guide's list of changed defaults before upgrading and grep for bare border and divide classes.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: TaxiDex, QistLock, Taskvare.