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

@carefully-coded/react-text-gradient

v1.0.6

Published

A simple static or animated text gradient react component

Downloads

907

Readme

React-Text-Gradient

Icon

A simple React component for awesome, animated or static text gradients.

Documentation + Examples

The library consists of a single component Text which when wrapped around text or a component containing text applies a gradient to it.

Installation

Install it from npm:

npm install @carefully-coded/react-text-gradient

Or with Yarn:

yarn add @carefully-coded/react-text-gradient

Usage

Static gradient text

Add a simple static gradient to your text:

import Text from 'react-text-gradient';
...
<Text gradient={{ from: '#818CF8', to: '#5B21B6' }}>Some fancy text</Text>

Animated gradient text

Use the animateTo prop to apply a specific gradient to animate to, or use animate to animate between the from and to positions of the initial gradient. Make sure to not set the same prop for animateTo and gradient or you will animate between the same color (i.e nothing will happen)

Animate between the from and to colors

import Text from 'react-text-gradient';

<Text 
  gradient={{ from: '#818CF8', to: '#5B21B6' }} 
  animate
  animationDuration={4000}
>
  Some fancy animated text
</Text>

Specific gradient to animate to:

import Text from 'react-text-gradient';

<Text 
  gradient={{ from: '#818CF8', to: '#5B21B6' }} 
  animateTo={{ to: '#818CF8', from: '#5B21B6' }} 
  animationDuration={4000}
>
  Some fancy animated text
</Text>

Enclosing tags

Any text inside of the component will have a gradient added, so it's easy just to add a gradient by wrapping existing components.

import Text from 'react-text-gradient';

<Text 
  gradient={{ from: '#818CF8', to: '#5B21B6' }} 
  animate
  animationDuration={4000}
>
  <h1>Large gradient text</h1>
</Text>

Linear gradient

Gradients are radial by default (we think this looks better most of the time). Set type to linear to create a linear gradient.

When adding a linear gradient, add a degree to pick what direction the gradient should be in - this defaults to 90.

import Text from 'react-text-gradient';

<Text 
  gradient={{ from: '#818CF8', to: '#5B21B6', type: 'linear', degree: 90 }} 
  animateTo={{ to: '#818CF8', from: '#5B21B6', degree: 120 }} 
  animationDuration={4000}
>
Some fancy text with a linear gradient
</Text>

Adding styles directly

Styles can be added to the text directly by specifying a style or className prop. Note that any background css attribute may be overwritten due to the applied gradient.

import Text from 'react-text-gradient';

<Text 
  style={{fontSize: '20px'}}
  gradient={{ from: '#818CF8', to: '#5B21B6' }} 
  animate
  animationDuration={4000}
>
  Text with specific font size
</Text>

<Text /> Props

type Gradient = {
  type?: 'linear' | 'radial';
  from?: string;
  to?: string;
  degree?: number;
};

interface Props extends React.HTMLAttributes<HTMLDivElement> {
  gradient: Gradient;
  animate?: Boolean;
  animateTo?: Gradient;
  animateDuration?: number;
}

| Prop Name | Type | Default | Description | | --- | ---- | ---- | --- | | gradient | Gradient | undefined | Starting gradient | | animate | Boolean | false | Animate the gradient text by transitioning between from and to colors | | animateTo | Gradient | undefined | Gradient to animate to | | animateDuration | number | 4000 | Duration of animation in ms |