A reusable, framework-agnostic CSS button with an animated RGB glow border, no JavaScript.
Live Preview: Open
index.htmlin your browser to see the animation in action, or visit the GitHub Pages demo
- Exact replica of the original animated RGB button
- No JavaScript required - pure CSS animation
- Customizable via CSS custom properties
- Accessible with keyboard navigation and reduced motion support
- Framework agnostic - works with any HTML/CSS setup
- RTL support included in demo
- Works with both
<button>and<a>elements
-
Copy the CSS file into your project:
styles/rgb-button.css -
Include it in your HTML:
<link rel="stylesheet" href="styles/rgb-button.css">
-
Add the class to any element:
<button class="rgb-button">Buy Subscription</button> <a class="rgb-button" href="#">RGB Link</a>
Open index.html in your browser to see:
- Default button with exact animation
- Size variations (small, medium, large)
- Custom gradient examples
- Accessibility features
Override CSS custom properties to customize the appearance:
<button
class="rgb-button"
style="--rgb-speed: 10s; --rgb-blur: 8px; --rgb-radius: 20px;"
>
Custom Button
</button>| Variable | Default | Description |
|---|---|---|
--rgb-gradient |
9-color rainbow | The animated gradient colors |
--rgb-background |
rgb(17, 17, 17) |
Main button background |
--rgb-after-background |
rgb(34, 34, 34) |
Background overlay color |
--rgb-foreground |
rgb(255, 255, 255) |
Text color |
--rgb-radius |
10px |
Border radius |
--rgb-padding-y |
0.6em |
Vertical padding |
--rgb-padding-x |
2em |
Horizontal padding |
--rgb-speed |
20s |
Animation duration |
--rgb-size |
400% |
Gradient background size |
--rgb-blur |
5px |
Glow blur intensity |
--rgb-glow-gap |
2px |
Glow border thickness |
--rgb-speed-super-fast |
3s |
Super fast animation speed |
--rgb-speed-fast |
8s |
Fast animation speed |
--rgb-speed-slow |
30s |
Slow animation speed |
--rgb-hover-opacity |
0.9 |
Opacity on hover |
--rgb-active-transform |
translateY(1px) |
Transform on click |
Note: The CSS now includes 50+ customizable variables for complete control over animation, positioning, typography, and interactive states!
.custom-gradient {
--rgb-gradient: linear-gradient(
45deg,
#ff006e, #8338ec, #3a86ff, #06ffa5, #ffbe0b, #ff006e
);
--rgb-speed: 8s;
--rgb-blur: 10px;
}- Duration: 20 seconds linear infinite
- Gradient Size: 400% to create smooth movement
- Blur Effect: 5px for soft glow
- Movement: Background position animates from 0px to 400% and back
.rgb-button::before {
/* Animated RGB glow layer */
background: var(--rgb-gradient);
background-size: 400%;
filter: blur(5px);
animation: glowing-rgb-button 20s linear infinite;
}
.rgb-button::after {
/* Dark background overlay for text readability */
background: rgb(34, 34, 34);
}- Keyboard Navigation: Full focus-visible support
- Reduced Motion: Animation automatically disables if user prefers reduced motion
- Color Contrast: Maintains readable text contrast
- Screen Readers: Works with standard button/link semantics
- β Chrome/Edge 88+
- β Firefox 89+
- β Safari 14+
- β Mobile browsers with CSS custom property support
Root Cause: The most common issue is that your system has "Reduce Motion" accessibility settings enabled, which disables CSS animations by default.
Solution:
- Check Motion Settings: On Windows, go to Settings β Accessibility β Visual effects β Animation effects (turn ON)
- Or Override CSS: The component includes a commented accessibility rule. If you want animation regardless of system settings, it's already disabled in the CSS.
Other potential causes: Some browsers have issues with CSS variables in animation properties or CSS cascade conflicts. The component now uses a reliable default animation speed and specific modifier classes to control the duration, which prevents conflicts.
<!-- Default animation (20 seconds) -->
<button class="rgb-button">Default Speed</button>
<!-- Fast animation (8 seconds) -->
<button class="rgb-button rgb-button--fast">Fast Button</button>
<!-- Slow animation (30 seconds) -->
<button class="rgb-button rgb-button--slow">Slow Button</button>
<!-- Custom speed using CSS variables -->
<button class="rgb-button rgb-button--custom" style="--rgb-speed: 15s;">
Custom Speed
</button>- Hard Refresh: Press
Ctrl+F5(Windows) orCmd+Shift+R(Mac) - Check Browser: Ensure you're using a modern, updated browser.
- Disable Extensions: Some browser extensions can interfere with CSS.
Predefined size classes are included:
<button class="rgb-button rgb-button--sm">Small</button>
<button class="rgb-button">Default</button>
<button class="rgb-button rgb-button--lg">Large</button>Control animation speed with these modifier classes:
<button class="rgb-button rgb-button--super-fast">Super Fast (3s)</button>
<button class="rgb-button rgb-button--fast">Fast (8s)</button>
<button class="rgb-button">Default (20s)</button>
<button class="rgb-button rgb-button--slow">Slow (30s)</button>
<button class="rgb-button rgb-button--custom" style="--rgb-speed: 15s;">Custom Speed</button>βββ styles/
β βββ rgb-button.css # Main component CSS
βββ index.html # Demo page with examples
βββ README.md # This documentation
- Uses CSS transforms and filters for hardware acceleration
- Single CSS file with no dependencies
- Optimized for smooth 60fps animation
MIT License - Feel free to use in personal and commercial projects.
- Enable GitHub Pages: Go to Settings β Pages β Deploy from branch β Select
mainbranch - Add Demo GIF:
- Create a
demo/folder - Add your screen recording as
rgb-button-demo.gif - Update the GIF path in README:

- Create a
- Add Tags: Create version tags for releases (
git tag v1.0.0)
rgb-button/
βββ demo/
β βββ rgb-button-demo.gif # Animation demo
β βββ screenshots/ # Additional images
βββ styles/
β βββ rgb-button.css # Main CSS file
βββ index.html # Demo page
βββ README.md # Documentation
βββ LICENSE # MIT License
βββ package.json # Optional: for npm publishing
cssanimationbuttonrgbglow-effectfrontendui-componentreusable
Inspired by and replicated from the original RGB button design on Nakhl Market Plus.
- π Issues: Report bugs or request features
- π‘ Discussions: Join the community discussion
- β Star this repo if you find it useful!
Made with β€οΈ for the CSS community