Gradient Border CSS Generator
Linear or conic stops, rounded corners, transparent or opaque cards and a rotating option. Previewed on dark and light, exported as raw CSS or Tailwind v4.
.gradient-border {
border: 2px solid transparent;
border-radius: 20px;
background:
linear-gradient(#0e0e11, #0e0e11) padding-box,
linear-gradient(135deg, #ff5f6d 0%, #ffc371 50%, #a855f7 100%) border-box;
}<div class="rounded-[20px] border-[2px] border-transparent [background:linear-gradient(#0e0e11,#0e0e11)_padding-box,linear-gradient(135deg,_#ff5f6d_0%,_#ffc371_50%,_#a855f7_100%)_border-box]">…</div>
FAQ
How do I make a gradient border with border-radius in CSS?
border-image ignores border-radius, so a rounded gradient border needs another technique. For an opaque card, stack two backgrounds: a solid fill clipped to padding-box and the gradient clipped to border-box, with a transparent border. For a transparent card, draw the gradient on a ::before layer and cut the middle out with mask-composite: exclude.
How do I get a gradient border on a transparent background?
Use the mask-composite technique. A ::before pseudo-element carries the gradient with padding equal to the border width, then two masks (content-box and full box) are composited with exclude, leaving only the ring. The card's background stays fully transparent.
How do I animate a rotating gradient border?
Register a custom property with @property --border-angle as an <angle>, use it as the gradient direction (conic-gradient(from var(--border-angle), …)), then animate it with @keyframes. Without @property the browser can't interpolate the angle, so the border would jump instead of rotate.
Does it work with Tailwind CSS v4?
Yes. The generator outputs arbitrary-value utilities such as [background:…_padding-box,…_border-box] and before:mask-exclude, plus an @theme animation token when rotation is on. Paste the markup and, for animation, the snippet into globals.css.
What is the browser support for CSS gradient borders?
All evergreen browsers. mask-composite: exclude ships unprefixed in Chrome 120+, Safari 15.4+ and Firefox 53+; the -webkit-mask-composite: xor line covers older WebKit. @property is supported in all current browsers.
More Free Design Tools
View all tools →Google Font Pairings Generator
16 curated Google Font heading + body pairings with live editable preview, Google Fonts link & Tailwind v4.
CSS Box Shadow Generator
Multi-layer CSS box-shadow studio with 8 curated presets, inset support & Tailwind utility export.
WCAG Color Contrast Checker
Check WCAG AA/AAA & UI contrast in HEX, RGB or OKLCH and auto-fix failing pairs in one click.
Retro Color Palette Generator
70s groove, 80s synthwave, 90s Memphis, Y2K Chrome, Mid-Century, Bauhaus & Kodak Film palettes.
Aesthetic Color Palette Generator
Matcha & Cream, Dark Academia, Japandi, Pastel Dream & harmony sliders with WCAG badges.
Brand Guidelines Generator
Build a live mini brand book and export HTML brand sheet, BRAND.md or CSS design tokens.
Tailwind v4 Palette Generator
Perceptually uniform 50–950 Tailwind v4 OKLCH scales and dark-mode palettes.
OKLCH Color Converter
Convert HEX to OKLCH and OKLCH to HEX with live Lightness, Chroma & Hue sliders.
CSS Glassmorphism Generator
Frosted-glass CSS & Tailwind v4 cards with live backdrop-filter blur and saturation.