A flexible React library for dynamic, animated, and glow-enabled gradient UI primitives.
Built with Framer Motion and vanilla CSS.
The core primitive. A single gradient line with support for:
- Vertical & horizontal orientation
- 6 animation modes —
entrance,scroll,flow,breathe,draw,none - Taper — fade the line to a point at
start,end, orbothends - Segments — render as dashed segments
- Glow — neon pulse with box-shadow
- Scroll-driven scaling — pass a Framer Motion
scrollProgressvalue or let it auto-measure
<GradientLine
gradient="linear-gradient(to bottom, #667eea, #764ba2, #f093fb, #667eea)"
thickness="4px"
length="200px"
flowSpeed={2}
taper="both"
/>A full-width section separator with an optional centered label.
<GradientDivider
gradient="linear-gradient(to right, #f093fb, #f5576c)"
label="Section Break"
glow={true}
/>Wraps any element with an animated gradient border.
<GradientBorder
gradient="linear-gradient(135deg, #4facfe, #00f2fe, #43e97b, #fa709a, #4facfe)"
thickness="2px"
radius="12px"
animate={true}
glow={true}
>
<div>Your content here</div>
</GradientBorder>An inline text element with a gradient underline. Supports always and hover trigger modes.
<p>
This text has a{' '}
<GradientUnderline
gradient="linear-gradient(to right, #4facfe, #00f2fe)"
trigger="hover"
>
gradient underline
</GradientUnderline>
</p>Extracts dominant colors from any image and returns a CSS linear-gradient string. Includes internal caching.
const { gradient, isLoaded } = useImageColors('/photo.jpg', {
direction: 'to bottom',
samples: 5
});
<GradientLine gradient={gradient} glow={true} />git clone https://github.com/alexpuliatti/gradient-components.git
cd gradient-components
npm install
npm run devOpen http://localhost:5173 to see the interactive demo page with live examples of every component and variant.
Copy the src/components/ui/ directory and src/hooks/useImageColors.js into your project. Import from the barrel:
import { GradientLine, GradientDivider, GradientBorder, GradientUnderline } from './components/ui';
import { useImageColors } from './hooks/useImageColors';Ensure framer-motion is installed as a dependency:
npm install framer-motionInclude the CSS classes from src/index.css (the /* Gradient Line */, /* Gradient Divider */, /* Gradient Border */, and /* Gradient Underline */ sections) in your stylesheet.
Full props documentation is available in src/docs/GradientLine.md.
| Prop | Type | Default | Description |
|---|---|---|---|
gradient |
string |
— | CSS background gradient |
orientation |
string |
'vertical' |
'vertical' or 'horizontal' |
thickness |
string |
'4px' |
Minor-axis dimension |
length |
string |
'100%' |
Major-axis dimension |
origin |
string |
'top' |
CSS transform-origin |
animation |
string |
'none' |
'none' · 'entrance' · 'scroll' · 'flow' · 'breathe' · 'draw' |
scrollProgress |
MotionValue |
null |
External scroll progress value |
glow |
boolean |
false |
Neon pulse glow effect |
taper |
string |
null |
'start' · 'end' · 'both' |
segments |
number |
0 |
Number of dashed segments |
flowSpeed |
number |
0 |
Seconds per flow cycle |
delay |
number |
0 |
Animation delay in seconds |
- React 19
- Framer Motion — scroll-driven animations, entrance transitions, spring physics
- Vanilla CSS — no Tailwind, no CSS-in-JS
- Vite — dev server and build
MIT