How to Embed a Gradient in Your Website
GradLab's Export Code feature generates a self-contained HTML file that runs the live gradient animation in a browser with WebGL support. This page shows how to embed it across different frameworks and platforms.
Step 1: Export your gradient
- Design your gradient in GradLab
- Click Export Code
- Click Download Code to save the
.htmlfile - Host the file on your server or CDN alongside your other assets
Method 1: iframe (universal)
The simplest method — works in plain HTML, any CMS, Webflow, Framer, Notion, and most no-code tools.
<iframe
src="/assets/gradient.html"
style="position:fixed; top:0; left:0; width:100%; height:100%; border:none; z-index:-1; pointer-events:none;"
title="Animated gradient background"
></iframe>Remove position:fixed and adjust sizing to embed the gradient as a contained element rather than a full-page background.
Method 2: React / Next.js
export default function GradientBackground() {
return (
<iframe
src="/gradient.html"
style={{
position: 'fixed',
top: 0,
left: 0,
width: '100%',
height: '100%',
border: 'none',
zIndex: -1,
pointerEvents: 'none',
}}
title="Animated gradient background"
/>
)
}Place the exported gradient.html file in your /public folder. Import and render the component in your layout or page file.
Method 3: CSS background (static PNG)
If you prefer a static image rather than a live animation, export a PNG from GradLab and apply it with CSS:
.hero {
background-image: url('/assets/gradient.png');
background-size: cover;
background-position: center;
}Method 4: Video background
Export an MP4 from GradLab and use the HTML5 video element:
<video
autoplay loop muted playsinline
style="position:fixed; top:0; left:0; width:100%; height:100%; object-fit:cover; z-index:-1;"
>
<source src="/assets/gradient.mp4" type="video/mp4">
</video>The muted and playsinline attributes are required for autoplay on iOS Safari.
Webflow
- Add an Embed element to your page
- Paste the iframe code from Method 1
- Host the exported
.htmlfile on a CDN (e.g. Cloudflare R2, AWS S3, or any static host) and update thesrcpath
Framer
- Use the HTML component from the component panel
- Paste the full contents of the exported
.htmlfile into the editor
Performance considerations
- The exported HTML uses WebGL — it runs on the GPU and is efficient in modern browsers
- On mobile, the animation is hardware-accelerated and runs smoothly on iOS and Android
- For very low-powered devices, consider a static PNG fallback using the
<noscript>or@mediaapproach - Set
pointer-events: noneon the iframe/video so it does not block clicks on overlying content