Home/Tools/Effects/Gradient Border Generator
Effects · Generator

Gradient Border Generator

Create gradient borders using the mask or border-image method, with border-radius support.

Method

Gradient

135°

Dimensions

3px
16px
20px

Preview

Gradient Border (mask)
Generated CSS
.element {
  position: relative;
  padding: 20px;
  border-radius: 16px;
  background: white;
}

.element::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 19px;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  z-index: -1;
}
100%
Free, no
sign-up needed
0
Code written
by hand
85+
CSS tools
in one place
<1s
Copy-ready
CSS instantly
What is this

What is the CSS Gradient Border Generator?

Generate gradient borders that support border-radius using the pseudo-element background-clip technique. Copy CSS that actually works.

Everything runs locally in your browser. Adjust the controls above, preview instantly, and copy clean, production-ready CSS — no account, no upload.

How to use

Using the CSS Gradient Border Generator

Everything lives in the panel at the top of this page. There is nothing to install — it all runs right here in your browser.

1

Set gradient colours and angle

Choose start and end colours and the gradient direction. This gradient becomes the border colour.

2

Set border thickness and radius

Enter the border thickness (inset value) and the element border-radius. The generator calculates the correct ::before border-radius automatically.

3

Copy the CSS

Click Copy to get the complete two-rule CSS including the position: relative and the ::before pseudo-element.

The output

What the generated code looks like

Clean, production-ready CSS — no vendor bloat, no unnecessary declarations.

styles.css
/* Gradient border with border-radius - pseudo-element technique */
.gradient-border {
  position: relative;
  background: white;
  border-radius: 12px;
  padding: 24px;
}
.gradient-border::before {
  content: '';
  position: absolute;
  inset: -2px; /* border thickness */
  border-radius: 14px; /* radius + border thickness */
  background: linear-gradient(135deg, #6C2EF5, #f97316);
  z-index: -1;
}

The inset value controls border thickness. The ::before border-radius must be the element border-radius plus the inset value.

Pro tips

Pro tips for better results

The element must have a solid background for this to work

The technique works by layering a gradient pseudo-element behind the element. If the element background is transparent, the gradient shows through the content area.

z-index: -1 on ::before requires position on the parent

The parent element must have position: relative for z-index: -1 on the ::before to push it behind the content without disappearing completely.

Inset controls border thickness

inset: -2px extends the pseudo-element 2px beyond the element on all sides, creating a 2px border. inset: -4px creates a 4px border. Use negative values.

FAQ

Frequently asked questions

CSS does not allow border-image and border-radius on the same element. The border-image property replaces the border with an image slice, which does not respect border-radius. The pseudo-element technique is the standard workaround.
No. Everything runs in your browser. Nothing is sent to a server.

From the blog

Read more