What Is the CSS Gradient Border Generator?
Create gradient borders on any element with the CSS mask technique, which keeps rounded corners and lets the inside stay transparent. Choose colors, angle, border width and radius with a live preview.
Why Use This Tool?
CSS has no gradient value for the border property, but a gradient layer masked down to a ring achieves the same effect. This tool generates that code for you with customizable gradient colors and direction.
How to Use This CSS Gradient Border
- Pick your gradient colors — Choose two or more colors for your border gradient. Use complementary or analogous colors for the best visual results.
- Set the gradient direction — Choose the angle or direction — diagonal gradients (135°) feel more dynamic than horizontal or vertical ones.
- Adjust border width and radius — Set the ring thickness and corner rounding to match your design; the ring follows the radius exactly.
- Copy the CSS — Copy the .gradient-border rule and its ::before rule. The ::before rule ends with pointer-events: none, so links, buttons and text inside the box stay clickable (see the worked example).
Worked example: what the copied CSS does, and why it turns off pointer events
This generator uses the mask technique, not border-image or background-clip. The element gets your fill color, and a ::before pseudo-element covering it (position: absolute; inset: 0) carries the gradient. That pseudo-element's padding equals your border width. Two masks are combined with mask-composite: exclude (-webkit-mask-composite: xor for WebKit). Together they cut away the content box, so only a ring as thick as the padding stays visible, and it follows border-radius. We rendered the default output in Chromium 141 on October 12, 2026. The ring pixels came out as gradient colors and the inside as the fill color, as intended.
Why the ::before rule ends with pointer-events: none. The masked-out middle is invisible, but the pseudo-element still sits on top of everything inside the box. On October 12, 2026 a button, a link and a line of text inside the generated box received nothing: a click on the button did not fire and the browser reported the box as the element under the pointer. The generated rule now includes pointer-events: none. With the copied CSS in Chromium 141 on October 13, the button and the link are the elements under the pointer, the click fires, and the ring still paints in the gradient colours.
Mask vs background-clip vs border-image
| Technique | Rounded corners | See-through inside | Notes |
|---|---|---|---|
| Mask on a pseudo-element (this tool) | Yes | Yes: the inside can stay transparent | Needs position: relative on the box and pointer-events: none on the pseudo-element |
Two backgrounds with background-clip: padding-box, border-box | Yes | No: the fill must be an opaque color | No extra element. The gradient sits behind a transparent border. |
border-image | No: corners stay square | Yes | The spec has the border image draw in place of the border style, and it isn't clipped by border-radius |
Support: the standard mask and mask-composite properties are in Chrome and Edge 120+, Firefox 53+ and Safari 15.4+, according to MDN's compatibility data. The prefixed -webkit-mask-composite: xor line covers older Chromium and Safari versions. Keep both lines, in the order the tool writes them.
Sources
Checked on .
Frequently Asked Questions
📖 Learn More
Related Article The Complete Guide to CSS Gradients → Related Article How to Create CSS Gradient Borders →Built by Derek Giordano · Part of Ultimate Design Tools