CSS `mask-image` Gradient Builder
Build linear and radial alpha masks visually, preview them locally, and export production-ready CSS.
Builder
Preview
Results
Metrics
Introduction
CSS masking allows you to reveal and hide parts of an element using alpha or luminance sources. Gradient masks are useful for fades, soft edges, and creative image treatments.
This builder helps you create gradient masks visually and export clean CSS.
How it works
The tool generates a gradient using black with varying alpha values. In an alpha mask, opaque areas show the element and transparent areas hide it.
- Linear mode uses an angle.
- Radial mode uses a shape and center position.
- Stops are sorted by position.
- The preview updates as you edit.
How to use
- Optionally upload a preview image.
- Select linear or radial mode.
- Adjust angle or radial center.
- Add and edit gradient stops.
- Generate and copy the CSS.
Practical example
A simple vertical fade can be written as:
mask-image: linear-gradient(90deg, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0) 100%);
Use cases
- Fading hero images.
- Softening image edges.
- Creating scroll-reveal effects.
- Building decorative overlays.
- Prototyping masking without design software.
Best practices
- Use subtle fades for content images.
- Ensure masked images retain meaningful alt text.
- Test masking at multiple viewport sizes.
- Include vendor prefixes where needed.
- Avoid masking essential text or controls.
Common mistakes
- Using fully transparent stops unintentionally.
- Forgetting prefixed CSS for broader support.
- Masking important UI elements.
- Using too many stops for simple fades.
- Assuming mask support is identical in all browsers.
Limitations
- The preview is approximate and depends on browser support.
- Luminance masking is not covered by this alpha-based builder.
- Uploaded preview images are not optimized.
- Complex mask compositions may require manual CSS.
Browser compatibility
Modern browsers support CSS masking to varying degrees. Include
-webkit-mask-image where broader compatibility is required.
FAQ
Is my image uploaded?
No. Preview images are processed locally in your browser.
Why use black with alpha?
For alpha masks, the color is less important than transparency. Black with alpha creates predictable stop values.
Do I need the vendor prefix?
It depends on your browser support requirements. Including
-webkit-mask-image improves compatibility in some browsers.
Can I use this for luminance masks?
This tool focuses on alpha gradients. Luminance masks require different source images and mask-mode handling.