npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-text-gradients-and-animations

v1.1.7

Published

Easily apply linear, radial, or conic gradient effects to text, as well as text gradient animations in React.

Downloads

32

Readme

Text Gradients and Animations for React

npm version Code size Build Status Coverage Status GitHub issues open License: MIT

Easily apply linear, radial, or conic text gradients to your React applications with only 3 components!

Add text gradient animations instantly!

No limit on color stops!

Demo

Installation and Importation

First, install the package:

npm i --save react-text-gradients-and-animations

Then import the LinearTextGradient, RadialTextGradient, or ConicTextGradient in your React application:

import {
  LinearTextGradient,
  RadialTextGradient,
  ConicTextGradient,
} from "react-text-gradients-and-animations";

LinearTextGradient

The LinearTextGradient component is used to apply a linear gradient on text:

<LinearTextGradient angle={45} colors={["#fafa6e", "#39b48e"]}>
  This text has linear gradient!
</LinearTextGradient>

The component can be used inside any HTML element tags.

If you input HTML element tags as children of LinearTextGradient, you will not see an output. To fix this, the LinearTextGradient component (or its parent component) must contain a display property (flex, inline-flex, etc.).

Note: Refresh the browser if the text is hidden underneath the background gradient.

Properties

| Prop | Description | Default Value | Type | Required | | ----------------------------- | -------------------------------------------- | ------------- | ------- | ----------------------------------- | | angle | The direction (angle) of the linear gradient | 0 | Integer | False | | colors | Array of colors (>= 2) | - | Array | True | | animate | Allow text gradient to be animated | False | Boolean | False (True if you want animations) | | animateDuration | Seconds it takes to do a full animation loop | 5 | Integer | False | | animateDirection | Direction of animation loop | "vertical" | String | False | | className | Custom CSS styling | - | String | False |

The ability to input as many colors as you need (>= 2) and any angle (0 - 360) for the linear gradient grants you more control, and a step closer to achieving your vision!

Types of animateDirection:

  • "horizontal"
  • "vertical"
  • "diagonal" --> infinitely loops from bottom left corner to top right corner

You can also add different intensities for each color:

  • "#fafa6e 50%"
  • "blue 25%"
  • "rgb(255, 0, 0) 75%"

RadialTextGradient

The RadialTextGradient component is used to apply a radial gradient on text:

<RadialTextGradient
  shape={"circle"}
  position={"center"}
  colors={["#fafa6e", "#39b48e"]}
>
  This text has radial gradient!
</RadialTextGradient>

The component can be used inside any HTML element tags.

If you input HTML element tags as children of RadialTextGradient, you will not see an output. To fix this, the RadialTextGradient component (or its parent component) must contain a display property (flex, inline-flex, etc.).

Note: Refresh the browser if the text is hidden underneath the background gradient.

Properties

| Prop | Description | Default Value | Type | Required | | ----------------------------- | -------------------------------------------- | ------------- | ------- | ----------------------------------- | | shape | Ending shape of radial gradient | "circle" | String | False | | position | Position of radial gradient | "center" | String | False | | colors | Array of colors (>= 2) | - | Array | True | | animate | Allow text gradient to be animated | False | Boolean | False (True if you want animations) | | animateDuration | Seconds it takes to do a full animation loop | 5 | Integer | False | | animateDirection | Direction of animation loop | "vertical" | String | False | | className | Custom CSS styling | - | String | False |

The ability to input as many colors as you need (>= 2) grants you more control, and a step closer to achieving your vision!

Types of shape:

  • "circle"
  • "ellipse"

Types of position:

  • "center"
  • "left"
  • "right"
  • "top"
  • "bottom"
  • "75px"
  • "40px 40px"
  • "25% 50%"
  • "0 0"

Types of animateDirection:

  • "horizontal"
  • "vertical"
  • "diagonal" --> infinitely loops from bottom left corner to top right corner

You can also add different intensities for each color:

  • "#fafa6e 50%"
  • "blue 25%"
  • "rgb(255, 0, 0) 75%"

ConicTextGradient

The ConicTextGradient component is used to apply a conic gradient on text:

<ConicTextGradient
  angle={0}
  position={"center"}
  colors={["#fafa6e", "#39b48e"]}
>
  This text has conic gradient!
</ConicTextGradient>

The component can be used inside any HTML element tags.

If you input HTML element tags as children of ConicTextGradient, you will not see an output. To fix this, the ConicTextGradient component (or its parent component) must contain a display property (flex, inline-flex, etc.).

Note: Refresh the browser if the text is hidden underneath the background gradient.

Properties

| Prop | Description | Default Value | Type | Required | | ----------------------------- | -------------------------------------------- | ------------- | ------- | ----------------------------------- | | angle | The direction (angle) of the conic gradient | 0 | Integer | False | | position | Position of conic gradient | "center" | String | False | | colors | Array of colors (>= 2) | - | Array | True | | animate | Allow text gradient to be animated | False | Boolean | False (True if you want animations) | | animateDuration | Seconds it takes to do a full animation loop | 5 | Integer | False | | animateDirection | Direction of animation loop | "vertical" | String | False | | className | Custom CSS styling | - | String | False |

The ability to input as many colors as you need (>= 2) and any angle (0 - 360) for the linear gradient grants you more control, and a step closer to achieving your vision!

Types of position:

  • "center"
  • "left"
  • "right"
  • "top"
  • "bottom"
  • "75px"
  • "40px 40px"
  • "25% 50%"
  • "0 0"

Types of animateDirection:

  • "horizontal"
  • "vertical"
  • "diagonal" --> infinitely loops from bottom left corner to top right corner

You can also add different intensities for each color:

  • "#fafa6e 50%"
  • "blue 25%"
  • "rgb(255, 0, 0) 75%"

Animation Code Example

All animations and animation properties will remain the same regardless of gradient type - (linear, radial, conic).

We will use the LinearTextGradient as our example:

<LinearTextGradient
  angle={90}
  colors={["#fafa6e", "#39b48e"]}
  animate
  animateDuration={10}
  animateDirection={"horizontal"}
>
  This text has an animated linear gradient!
</LinearTextGradient>

Remember, if you want to animate a gradient, you have to input the property animate (or animate={true}).

Since our linear gradient angle is 90 degrees, our colors are appearing in a vertical pattern. The animation works by translating the background, so we should use a horizontal animation direction to make the changing colors visible! (if we use the vertical animation direction, we will see nothing being animated).