Proposal: border-gradient property for native gradient borders
Proposal: border-gradient Property
Issue Summary
Currently, CSS lacks a dedicated property for applying gradient borders to elements. While workarounds exist using border-image, background-clip, and pseudo-elements, they have limitations that make implementing gradient borders cumbersome and inconsistent across browsers.
This issue proposes the introduction of a border-gradient property to simplify applying gradients to element borders in a native and intuitive way.
Problem Statement
Developers frequently seek to create gradient borders for UI elements, but the current methods have significant drawbacks:
border-imageis limited – It does not supportborder-radiusproperly and can behave unpredictably when the border width changes.- Pseudo-element workarounds (
::before/::after) – These require additional markup and complex masking techniques. - Lack of direct control – Achieving even simple gradient borders requires multiple CSS properties instead of a single, intuitive declaration.
A dedicated border-gradient property would improve developer experience and performance by eliminating these workarounds.
Proposed Feature
Introduce a border-gradient property that allows developers to apply a gradient directly to borders, similar to how border-color works but supporting gradients.
Proposed Syntax
.element {
border: 5px solid;
border-gradient: linear-gradient(to right, red, blue);
}
Expected Behavior
border-gradientaccepts any valid CSS gradient (linear-gradient,radial-gradient,conic-gradient).- It respects
border-radiusand follows the natural curvature of rounded borders. - It works with
border-width, adapting to different border thicknesses without requiring additional properties.
Comparison with Existing Workarounds
| Feature | border-image |
Pseudo-elements | border-gradient (Proposed) |
|---|---|---|---|
Supports border-radius |
No | Yes (Complex) | Yes (Native) |
| Requires extra markup | No | Yes | No |
Works with border-width |
No (Scaling issues) | Yes | Yes |
| Intuitive to use | No | No | Yes |
Use Cases
-
Designing modern UI components
- Buttons, cards, and other elements often use gradient borders for a sleek appearance.
-
Theming and branding
- Websites and applications can dynamically change gradient borders to match themes without complex CSS tricks.
-
Accessibility and visual clarity
- Designers can use subtle gradient effects for better visual distinction while maintaining accessibility.
Why This Feature is Valuable
- Improves developer experience – Reduces reliance on hacks and workarounds.
- Better maintainability – A single property simplifies styling compared to multiple CSS rules.
- Performance benefits – Eliminates the need for extra DOM elements or masking techniques.
Next Steps
- Gather feedback from developers and browser vendors on feasibility.
- Discuss potential edge cases, such as handling transparency, animations, and interaction with existing border properties.
- Determine if the feature should be prototyped in Houdini before standardization.
Request for Discussion
We would like to hear feedback from the CSS Working Group and community members on:
- Technical feasibility – Are there rendering or performance concerns?
- Use case validation – Are there strong industry needs for this feature?
- Alternative approaches – Are there better ways to achieve gradient borders?
Related Discussions & Community Interest
- CSS Tricks article on Gradient Borders
- Stack Overflow question: "How to do gradient borders in CSS?"
@DylanDuff hi. you might want to check out background-clip: border-area; it's a new property and there are implementations going on.
https://webkit.org/blog/16214/background-clip-border-area/
@DylanDuff hi. you might want to check out
background-clip: border-area; it's a new property and there are implementations going on. https://webkit.org/blog/16214/background-clip-border-area/
I wasn’t aware of this thanks for the link :)
…i did not mean to close this, I still think it would be useful to get feedback whether general consensus is that background-clip should be the recommended way moving forward or a specific border gradient property would be more beneficial
What would this add over background-clip: border-area?
background-clip: text; and background-clip: border-area; are incredibly illogical properties for covering both of there use cases. These properties are clearly hacks of background layers that have somehow been built directly into CSS. No one who doesn't already know that these properties exist would think that changing the color or border-color to transparent and then using a clipped background layer as fill would be the native CSS way to fill text or a border with an image.
Borders should appear on the border layer. Devs shouldn't have to potentially manage multiple background images to "fake" a border.
The actual logical things that I've seen people who are new to CSS write are for gradient borders and text are:
color: linear-gradient();
border: solid 3px linear-gradient();
Personally, I still think that border-image is salvageable for this. Potentially adding some sort of keyword to switch modes into having border-image just clip a source-image to the border-area would making it work well for this use case (outset would have t e disabled I guess?).
What this would lose from background-clip: border-area is the ability to layer multiple images. This could be restored with the @image proposal.
Or could some sort of border-fill with the same options as image fill from the stroke-fill spec