SolutionsCase StudiesAI ToolsResourcesAboutContact
Get Your Free AI Automation Audit Book a Free 30-Minute Strategy Call
Playground~/frontend Open editor

~/css/gradient-ui

7 CSS Gradient UI

7 Pure CSSPublished 2026-10-05Free · no sign-up

Seven components that use gradients well: a hero with a deep gradient and glow, a white card with gradient accents, a pricing card with a gradient border, a gradient navigation bar, an input whose border becomes a gradient on focus, stat tiles and a footer that fades into colour.

01. Gradient Hero Section

Gradient UIHero

A hero with a deep multi-stop gradient, a soft radial glow behind the headline and a white primary button. Every stop of the gradient keeps the white headline above 4.5:1 contrast.

View code
<section class="gu1"><h3>Ship faster with less code</h3><p>Components, docs and hosting in one place.</p><a href="#start">Start free</a></section>
.gu1 { display: grid; justify-items: center; gap: 10px; width: 340px; max-width: 100%; padding: 32px 20px; box-sizing: border-box; border-radius: 20px; background: radial-gradient(circle at 50% 0, rgba(167,139,250,.5), transparent 60%), linear-gradient(160deg, #1e1b4b, #4c1d95 55%, #831843); text-align: center; font: 14px Inter, system-ui, sans-serif; }
.gu1 h3 { margin: 0; color: #fff; font-size: 26px; line-height: 1.15; text-wrap: balance; } .gu1 p { margin: 0 0 6px; color: #e9d5ff; }
.gu1 a { padding: 11px 18px; border-radius: 10px; background: #fff; color: #1e1b4b; font-weight: 800; text-decoration: none; }
.gu1 a:focus-visible { outline: 3px solid #f0abfc; outline-offset: 3px; }

02. Gradient Accent Feature Card

Gradient UICard

A white card with a gradient icon tile and a gradient underline under the title, so colour is an accent rather than a flood. Small gradient touches feel modern without making text harder to read.

View code
<article class="gu2"><span class="ic" aria-hidden="true">⚡</span><h3>Instant sync</h3><p>Changes appear on every device within a second.</p></article>
.gu2 { width: 240px; max-width: 100%; padding: 20px; box-sizing: border-box; border: 1px solid #e4e7ec; border-radius: 16px; background: #fff; font: 14px/1.5 Inter, system-ui, sans-serif; }
.gu2 .ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #f97316, #db2777); font-size: 20px; }
.gu2 h3 { display: inline-block; margin: 12px 0 6px; padding-bottom: 4px; color: #101828; background: linear-gradient(90deg, #f97316, #db2777) bottom / 100% 3px no-repeat; }
.gu2 p { margin: 0; color: #475467; }

03. Gradient Border Pricing Card

Gradient UIBorder

The recommended plan wrapped in a rounded gradient border using the padding-box and border-box background trick, so the border follows the radius exactly. The card inside is solid, keeping the content easy to read.

View code
<article class="gu3"><p class="k">Recommended</p><h3>Pro</h3><p class="pr">$24<span>/mo</span></p><a href="#pro">Choose Pro</a></article>
.gu3 { width: 220px; max-width: 100%; padding: 20px; box-sizing: border-box; border: 2px solid transparent; border-radius: 18px; background: linear-gradient(#111727, #111727) padding-box, linear-gradient(135deg, #22d3ee, #a855f7, #f43f5e) border-box; color: #cbd5e1; font: 14px Inter, system-ui, sans-serif; }
.gu3 .k { margin: 0; color: #c4b5fd; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.gu3 h3 { margin: 4px 0; color: #fff; font-size: 22px; } .gu3 .pr { margin: 0 0 14px; color: #fff; font-size: 32px; font-weight: 800; } .gu3 .pr span { color: #94a3b8; font-size: 14px; }
.gu3 a { display: block; padding: 10px; border-radius: 10px; background: linear-gradient(90deg, #7c3aed, #be185d); color: #fff; font-weight: 700; text-align: center; text-decoration: none; }
.gu3 a:focus-visible { outline: 3px solid #f0abfc; outline-offset: 2px; }

04. Gradient Navigation Bar

Gradient UINavigation

A navigation bar with a horizontal gradient and white links, plus a thin brighter line along the bottom. The current page gets a translucent white pill, which works on any part of the gradient.

View code
<nav class="gu4" aria-label="Main"><a class="logo" href="#home">Nova</a><a href="#product" aria-current="page">Product</a><a href="#pricing">Pricing</a><a href="#docs">Docs</a></nav>
.gu4 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; width: 400px; max-width: 100%; padding: 8px 12px; box-sizing: border-box; border-radius: 14px; background: linear-gradient(90deg, #1d4ed8, #6d28d9); box-shadow: inset 0 -2px 0 rgba(255,255,255,.25); font: 600 14px Inter, system-ui, sans-serif; }
.gu4 a { padding: 7px 12px; border-radius: 999px; color: #fff; text-decoration: none; }
.gu4 .logo { margin-right: auto; font-weight: 900; }
.gu4 a[aria-current] { background: rgba(255,255,255,.2); }
.gu4 a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

05. Gradient Focus Ring Input

Gradient UIForm

A text field whose border turns into a gradient when focused, using the two-background border technique on a wrapper with :focus-within. At rest the border is plain grey, so colour appears only where attention is.

View code
<div class="gu5"><label for="gu5i">Email address</label><div class="w"><input id="gu5i" type="email" placeholder="you@example.com"></div></div>
.gu5 { display: grid; gap: 6px; width: 280px; max-width: 100%; font: 14px Inter, system-ui, sans-serif; }
.gu5 label { color: #101828; font-weight: 700; }
.gu5 .w { border: 2px solid transparent; border-radius: 12px; background: linear-gradient(#fff, #fff) padding-box, linear-gradient(#98a2b3, #98a2b3) border-box; }
.gu5 .w:focus-within { background: linear-gradient(#fff, #fff) padding-box, linear-gradient(90deg, #06b6d4, #7c3aed, #db2777) border-box; }
.gu5 input { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; font: inherit; }
.gu5 input:focus { outline: none; }

06. Gradient Stat Tiles

Gradient UIData

Three stats each on its own gradient tile, with large numbers and small labels. The gradients share one angle and similar lightness so the tiles feel like a set, and white text sits on stops dark enough to pass contrast.

View code
<dl class="gu6"><div style="--g:linear-gradient(135deg,#0e7490,#1e3a8a)"><dt>Visitors</dt><dd>48k</dd></div><div style="--g:linear-gradient(135deg,#6d28d9,#831843)"><dt>Orders</dt><dd>1.2k</dd></div><div style="--g:linear-gradient(135deg,#b45309,#9f1239)"><dt>Revenue</dt><dd>$64k</dd></div></dl>
.gu6 { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; width: 340px; max-width: 100%; margin: 0; font-family: Inter, system-ui, sans-serif; }
.gu6 div { display: flex; flex-direction: column-reverse; padding: 14px; border-radius: 14px; background: var(--g); }
.gu6 dt { color: #f1f5f9; font-size: 12px; } .gu6 dd { margin: 0; color: #fff; font-size: 24px; font-weight: 800; }

About these CSS Gradient UI

Check every stop

Text on a gradient has to pass contrast against its lightest stop, not its average. Test the heading against each colour it crosses.

Accent or flood

A gradient can fill a hero or sit on a small accent such as an icon tile or underline. Small accents feel modern without risking readability.

Borders that follow the radius

Two backgrounds, a solid one clipped to padding-box and the gradient clipped to border-box, draw a gradient border that respects border-radius exactly.

Keep a family

Use the same angle and similar lightness for related gradients so tiles and buttons look like a set rather than random colours.

Frequently asked questions

Do gradients slow pages down?

No. They are drawn by the browser with no image download.

How do I animate a gradient?

See the gradient animations collection for position, @property and hue techniques.

Can gradients replace images?

For backgrounds and decorative shapes, often yes.