Europe/Kyiv
Posts

Gradient Borders in CSS: Why It's Harder Than It Looks

May 6, 2026
Tried adding a gradient border and noticed it "jumps" during color transitions? 😬 That's not a Tailwind bug — it's a CSS limitation. There is no native border-gradient property yet. So developers have been working around it for years. Here are the three most common approaches: The most straightforward option. Works well for simple cases.
.box {
  border: 3px solid transparent;
  border-image: linear-gradient(90deg, #e96cff, #6c9eff) 1;
}
The catch: border-image doesn't support border-radius. So if you need rounded corners, this approach won't work. More stable and supports rounded corners. The idea: set a gradient as the background, then clip the inner content.
.box {
  border: 3px solid transparent;
  border-radius: 12px;
  background: linear-gradient(white, white) padding-box,
              linear-gradient(90deg, #e96cff, #6c9eff) border-box;
}
Clean, no extra wrapper element. This is the most widely used approach today. The most flexible option — works best for complex animations and transitions.
.box {
  position: relative;
  border-radius: 12px;
  z-index: 0;
}

.box::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  background: linear-gradient(90deg, #e96cff, #6c9eff);
  z-index: -1;
}
More complexity, but gives you the most control — especially for hover and transition effects.
ApproachRounded cornersTransitionsComplexity
border-imageNoLimitedLow
background-clipYesYesLow
Pseudo-elementYesYesMedium
For most cases, background-clip is the sweet spot. The CSS Working Group is already discussing a native border-gradient property. One day this will just work — no jumps, no workarounds. Until then: pick your workaround and be patient. 💡