Components & UI Animation — Reference
Gradient Flow on Hover
The Gradient Flow on Hover is a CSS animation component that an animated gradient that flows across a button's border and background when the user hovers. Great for CTAs, navigation items, or any interactive element that benefits from a colorful hover state. It ships as self-contained HTML and CSS with no external dependencies, making it drop-in ready for any modern web project regardless of framework or build system.
When to use the Gradient Flow on Hover
- Landing page hero backgrounds and section dividers
- Product cards, navigation items, and link interactions
- Primary and secondary CTA interaction feedback
- Component libraries and design systems that need consistent motion patterns
- Progressive enhancement — works in all modern browsers, degrades gracefully
Performance characteristics
- GPU-accelerated — uses CSS transform and opacity so compositing happens off the main thread
- Zero JavaScript dependency in most configurations — no framework, no bundler required
- Approximately 60 fps on any device that supports CSS animations (Chrome 43+, Firefox 16+, Safari 9+)
- Self-contained in a single HTML file — no npm install, no build step, paste and ship
How it compares
Unlike equivalent JavaScript implementations, the Gradient Flow on Hover does not require any runtime library — there is nothing to install, bundle, or load asynchronously.
Compared to animated GIFs or video embeds, this CSS component is resolution-independent, theme-able via CSS custom properties, and weighs a fraction of the equivalent media file.
Source code
CSS
.btn { padding: 14px 28px; border: none; border-radius: 10px; background: #18181b; color: #fff; font-weight: 600; cursor: pointer; position: relative; overflow: hidden; }
.btn::before { content: ''; position: absolute; inset: -2px; background: linear-gradient(90deg, #3b82f6, #22d3ee, #38bdf8, #3b82f6); background-size: 300% 300%; border-radius: 12px; z-index: -1; animation: flow 3s ease infinite; opacity: 0; transition: opacity 0.3s; }
.btn:hover::before { opacity: 1; }
.btn span { position: relative; z-index: 1; }
@keyframes flow { 0%,100%{background-position:0% 50%} 50%{background-position:100% 50%} }
body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f0f0f; }HTML
<button class="btn"><span>Hover me</span></button>Full source
<!DOCTYPE html>
<html><head><style>
.btn { padding: 14px 28px; border: none; border-radius: 10px; background: #18181b; color: #fff; font-weight: 600; cursor: pointer; position: relative; overflow: hidden; }
.btn::before { content: ''; position: absolute; inset: -2px; background: linear-gradient(90deg, #3b82f6, #22d3ee, #38bdf8, #3b82f6); background-size: 300% 300%; border-radius: 12px; z-index: -1; animation: flow 3s ease infinite; opacity: 0; transition: opacity 0.3s; }
.btn:hover::before { opacity: 1; }
.btn span { position: relative; z-index: 1; }
@keyframes flow { 0%,100%{background-position:0% 50%} 50%{background-position:100% 50%} }
body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f0f0f; }
</style></head><body><button class="btn"><span>Hover me</span></button></body></html>Frequently asked questions
How do I add the Gradient Flow on Hover to my project?
Copy the full source code from the code block on this page. Paste the <style> block into your stylesheet (or a <style> tag in your HTML head) and the HTML markup into your template. No npm install or build step is required — the animation is self-contained. To customize colors, speed, or size, use Grepped's workspace at grepped.dev/animations/components-ui/gradient-flow-hover.
Is the Gradient Flow on Hover free to use?
Yes. All Grepped preset animations are free to use in personal and commercial projects. You may copy, modify, and redistribute the code without attribution. The only limitation is that you may not resell the presets themselves as part of a competing animation library.
Does the Gradient Flow on Hover work on mobile browsers?
Yes. The Gradient Flow on Hover uses standard CSS animations and transforms that are supported in all modern mobile browsers — Chrome for Android, Safari on iOS 9+, Samsung Internet, and Firefox for Android. Where JavaScript is used for interactivity (e.g. cursor effects), it falls back gracefully on touch devices.
Can I customize the Gradient Flow on Hover's colors, speed, or size?
Yes. Open the live customization workspace at grepped.dev/animations/components-ui/gradient-flow-hover to adjust the animation with real-time sliders, color pickers, and toggles — no code required. For deeper changes, the source code uses CSS custom properties (variables) so you can edit them directly in your stylesheet.
Want to customize this animation or generate a new one from a text prompt?
Open in Workspace — it's free