Gradient Border
渐变边框
Color transitions along the outline while the interior keeps a solid color.
Where to use it
Emphasize a feature tile, badge or selected card. A thin color band works best when only one or two items need emphasis. Pair it with a label if the border marks an important state.
Practical example
A document-signing app puts a blue-to-violet border around the currently selected template in a grid of six. The template keeps its white background, and a “Selected” label confirms the choice.
AI prompt
Add a Gradient Border to [target card] with a transparent border and two background layers. Clip the solid interior to the padding box and the gradient to the border box. Preserve the same radius and provide a solid border fallback for forced colors.
Example code
Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.
View HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Gradient Border</title>
<style>
:root {
color-scheme: dark;
--demo-bg: #171629;
--demo-ink: #f8f5ff;
--demo-accent: #b9a6ff;
--demo-muted: #bfbbd3;
font-family: system-ui, sans-serif;
color: var(--demo-ink);
background: var(--demo-bg);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input { font: inherit; }
.demo {
display: grid;
place-items: center;
align-content: center;
min-height: 100vh;
padding: 14px;
overflow: hidden;
background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
}
.demo-button {
border: 1px solid #ffffff3d;
border-radius: 7px;
background: #ffffff12;
color: var(--demo-ink);
padding: 6px 11px;
font-size: 12px;
cursor: pointer;
}
:focus-visible {
outline: 2px solid var(--demo-accent);
outline-offset: 3px;
}
.visual-specimen {
width: min(100%, 290px);
height: 124px;
display: grid;
place-items: center;
position: relative;
isolation: isolate;
}
.gradient-rim {
padding: 18px 22px; border: 2px solid transparent; border-radius: 16px; font-weight: 700;
background: linear-gradient(#21182d, #21182d) padding-box, linear-gradient(120deg, #f2a78b, #db8ef4 52%, #69dfbf) border-box;
}
@media (forced-colors: active) { .gradient-rim { border-color: currentColor; } }
</style>
</head>
<body>
<main class="demo">
<div class="visual-specimen" aria-hidden="true"><span class="gradient-rim">Collection</span></div>
</main>
</body>
</html>Original example by UI Skills