Gradient Border Card
Card with a gradient border frame.
Gradient border
A 2px gradient frame makes any card feel premium.
<div class="max-w-sm rounded-3xl bg-gradient-to-br from-indigo-500 via-purple-500 to-pink-500 p-[2px]">
<div class="rounded-[22px] bg-white p-6">
<h3 class="text-lg font-bold text-slate-900">Gradient border</h3>
<p class="mt-2 text-sm text-slate-500">A 2px gradient frame makes any card feel premium.</p>
</div>
</div>Free to use in personal and commercial projects. No attribution required.
Variants
Same component, different looks. Preview each one live and copy the code you like.
Sunset
Warm sunset frame for creative and lifestyle brands.
Gradient border
A 2px gradient frame makes any card feel premium.
Dark inner
Dark inner surface makes the gradient frame glow on night interfaces.
Gradient border
A 2px gradient frame makes any card feel premium.
Thick frame
Thicker 4px frame for featured cards that must stand out.
Gradient border
A bolder 4px frame for featured and highlighted cards.
About this gradient border card
A gradient border turns an ordinary card premium. The 2px frame flowing from indigo to pink catches the eye before the content does, which makes it ideal for featured plans, highlighted posts, or anything you want to elevate above siblings.
The technique mirrors the gradient button: a gradient wrapper with p-[2px], inner white card with slightly smaller radius. The rounded-[22px] inner radius accounts for the 2px border so corners stay concentric.
Use one gradient-bordered card per group. If every card has the rainbow frame, the effect becomes noise. It is a spotlight, not a theme.
A row of pricing tiers or a grid of posts presents everything as equally important, and equally important means the user must work to find what you want them to see. A gradient border is a spotlight you wrap around one card: the eye lands on the colorful frame first, then reads inward. It manufactures hierarchy without reordering the layout or rewriting the content.
The outer div wears rounded-3xl, bg-gradient-to-br from-indigo-500 via-purple-500 to-pink-500, and p-[2px]: the padding itself is the border. The inner div is bg-white with rounded-[22px], the outer radius minus the 2px border, so the corners stay concentric. Content lives inside the inner card, completely untouched by the gradient machinery around it.
On dark themes, make the inner card bg-slate-900 so the frame ignites against it. Thicken to p-[3px] on large cards, since borders need to scale with canvas or they disappear. Steer the gradient direction (to-br, to-r) to echo the visual flow of the surrounding section rather than fighting it.
The mistake is letting children overflow the inner card's rounded corners. A square-cornered image or a full-bleed header inside the card pokes past the inner radius and shatters the concentric illusion, making the frame look broken at the corners. Put overflow-hidden on the inner card, or match the children's radii to it, so everything inside respects the curve.
Where to use it
- ✓ Featured pricing tiers
- ✓ Highlighted blog posts
- ✓ Premium badges
- ✓ Winner announcements
Customization tips
Thicken to p-[3px] for more presence. Animate the gradient with background-position keyframes for a living border. Match gradient colors to the featured content.
Design notes
When to use
Use it to spotlight one card in a group: the featured pricing tier, a highlighted blog post, or a winner announcement. The 2px gradient frame catches the eye before the content does, which is exactly what a featured item needs. It works because its siblings stay plain.
What to avoid
Do not frame every card with the gradient border. When all cards shout, the spotlight becomes noise and the featured item disappears again. Keep the border thin; thick gradient frames look gaudy.
Accessibility
The border is decorative, so it needs no accessible name, but make sure the card content itself has proper heading structure. Do not use the gradient as the only way to mark something as featured; add a text badge like Most popular.
Frequently asked questions
How do I make a gradient border on a card?
Wrap the card in a gradient div with p-[2px], then give the inner card a matching background and slightly smaller border-radius. The padding becomes the visible border.
Why is my inner corner not aligning?
Reduce the inner border-radius by the border width. For a 24px outer radius with 2px border, use 22px inner.
Can gradient borders animate?
Yes, animate background-position on the gradient wrapper for a flowing effect, or use a conic gradient with rotation for a spinning border.
How do I make a gradient border with rounded corners?
Do not use border-image, it ignores border-radius. Instead layer two backgrounds on a transparent border: the card's background clipped to padding-box and the gradient clipped to border-box. This element uses that technique, which is why its rounded corners keep the gradient ring perfectly smooth.
Why is my gradient border showing through the middle of the card?
The inner background layer is not covering the gradient fully, usually because background-clip is wrong or the border is not transparent. The inner layer must be clipped to padding-box and the border set to transparent so the gradient only peeks through at the border ring.
Can I use a conic gradient for the border instead of linear?
Yes, the border-box background layer can be any gradient type. A conic gradient gives a color-wheel ring, and animating its rotation with @property creates a spinning border effect. Keep the inner padding-box layer solid so the card content stays readable over the animated edge.
Customize it with our tools
Related elements
Glass card
Frosted glass effect with backdrop blur. Looks best over a colorful background.
Glass Card
Frosted glass card with subtle border and blur.
Hover lift card
Subtle lift plus shadow sells interactivity without layout shift.
Hover Lift Card
Card that lifts with a deepening shadow on hover.
Revenue
$48.2k
12.4%
Stat Card
Metric card with trend indicator.