rgt

1.0.7 • Public • Published

view on npmnpm module downloads per month

rgt homepage

React Gradient Text (rgt)

After finding myself adding this kind of gradient colors on text across multiple different projects, I got tired of having to re-write my own react gradient text components on each project, and so I decided to create a tiny and extremely simple and lightweight component that can be used in any project. It simply wraps whatever text children are passed to it in a <span> tag that applies a linear gradient to it.

The goal is to be able to use a Gradient component across any project to give a color gradient style to any kind of text the following way:

import react from 'react'
import Gradient from 'rgt'
import Text from 'UI-Library'

const Component = () => <>
    <h1>
        <Gradient dir="top-to-bottom" from="#5F3BB7" to="#55D4FF">
            You can wrap text that goes inside an html text component
        </Gradient>
    </h1>
    <Text>
        <Gradient dir="top-to-bottom" from="#5F3BB7" to="#55D4FF">
            But you can also wrap text that goes into a custom react text component
        </Gradient>
    </Text>
    <a>
        <Gradient dir="top-to-bottom" from="#5F3BB7" to="#55D4FF">
            You can even apply these styles to a link!
        </Gradient>
    </a>
</>

Installation

Currently available on npm, you can just run the following to install this lightweight dependency into your project.

npm install rgt

Usage

We have already seen a few examples of how the Gradient component can be used. However, what can I pass as props, you maye be asking yourself?

Gradient Props

name type options
dir string left-to-right or right-to-left or top-to-bottom or bottom-to-top
from string any hex color value
to string any hex color value

License

Copyright 2021 Borja Leiva

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Package Sidebar

Install

npm i rgt

Homepage

rgt.borja.ai

Weekly Downloads

8

Version

1.0.7

License

ISC

Unpacked Size

5.25 kB

Total Files

4

Last publish

Collaborators

  • borjadotai