A lightweight React component to render text with CSS gradient colors.
npm install @_gmdev/react-gradient-textimport { ReactGradientText } from "@_gmdev/react-gradient-text";
function App() {
return (
<ReactGradientText
text="Hello Gradient!"
colors={["#ff0000", "#00ff00", "#0000ff"]}
/>
);
}| Prop | Type | Default | Description |
|---|---|---|---|
text |
string |
required | Text to render |
colors |
string[] |
required | Array of CSS color strings for the gradient |
direction |
string |
"to right" |
CSS gradient direction (e.g. "45deg") |
as |
ElementType |
"span" |
HTML element to render |
className |
string |
undefined |
Additional CSS class |
style |
CSSProperties |
undefined |
Additional inline styles (merged with gradient) |
animation |
AnimationType |
undefined |
Animation triggered on viewport entry (fade-in-*, scramble) |
duration |
number |
500 |
Animation duration in milliseconds |
Animations are triggered automatically when the element enters the viewport via IntersectionObserver.
Available animations:
fade-in-up,fade-in-down,fade-in-left,fade-in-rightfade-in-top-left,fade-in-top-right,fade-in-bottom-left,fade-in-bottom-rightscramble— characters shuffle progressively until the final text is revealed
<ReactGradientText
text="Hello!"
colors={["#667eea", "#764ba2"]}
animation="fade-in-up"
duration={800}
/><ReactGradientText
text="Scramble!"
colors={["#ff6b6b", "#4ecdc4"]}
animation="scramble"
duration={1000}
/><ReactGradientText
text="Diagonal!"
colors={["#667eea", "#764ba2"]}
direction="45deg"
/><ReactGradientText
text="I am a heading"
colors={["#f093fb", "#f5576c"]}
as="h1"
/><ReactGradientText
text="Rainbow Text"
colors={["#ff0000", "#ff7f00", "#ffff00", "#00ff00", "#0000ff", "#4b0082", "#9400d3"]}
/># Install dependencies
npm install
# Run tests
npm test
# Run Storybook
npm run storybook
# Build the library
npm run buildMIT