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-native-text-gradient

v0.1.7

Published

Text gradient for React-Native

Downloads

5,552

Readme

react-native-text-gradient

npm version Dependency Status typings included npm

React-Native text gradient component for iOS & Android.

Getting started

$ npm install react-native-text-gradient --save

Mostly automatic installation

$ react-native link react-native-text-gradient

Manual installation

link

If you are using Cocoapods you need to follow the manual installation guide.

Status

  • Component works as drop-in replacement for standard Text component and it is possible to have nested gradients.
  • React-Native:
    • with rn >= 0.59.0 use latest version and patch;
    • with rn >= 0.56.0 use 0.0.17 and patch;
    • with rn >= 0.55.0 use 0.0.9;
    • with rn >= 0.54.0 use 0.0.7;
    • with rn >= 0.53.1 use 0.0.4;
    • rn 0.53.0 is not supported;
    • with rn >= 0.50.0 use 0.0.3.

Example

import { LinearTextGradient } from "react-native-text-gradient";

<LinearTextGradient
  style={{ fontWeight: "bold", fontSize: 72 }}
  locations={[0, 1]}
  colors={["red", "blue"]}
  start={{ x: 0, y: 0 }}
  end={{ x: 1, y: 0 }}
>
  THIS IS TEXT GRADIENT
</LinearTextGradient>;

| iOS | Android | | :-----------------------------------------------: | :----------------------------------------------------: | | | |

Usage

LinearTextGradient

Interface is similar to Text & LinearGradient

colors

An array of at least two color values that represent gradient colors. Example: ['red', 'blue'] sets gradient from red to blue.

start

An optional object of the following type: { x: number, y: number }. Coordinates declare the position that the gradient starts at, as a fraction of the overall size of the gradient, starting from the top left corner. Example: { x: 0.1, y: 0.1 } means that the gradient will start 10% from the top and 10% from the left.

end

Same as start, but for the end of the gradient.

locations

An optional array of numbers defining the location of each gradient color stop, mapping to the color with the same index in colors prop. Example: [0.1, 0.75, 1] means that first color will take 0% - 10%, second color will take 10% - 75% and finally third color will occupy 75% - 100%.

useViewFrame

Optional. If true gradient will be calculated for text view background frame rather than text frame.

<LinearTextGradient
  numberOfLines={1}
  useViewFrame={true}
  locations={[0.5, 0.95]}
  // note colors like '#FF000000' are used for seamless transition to transparent
  colors={["#FF0000", "#FF000000"]}
  start={{ x: 0, y: 0 }}
  end={{ x: 1, y: 0 }}
>
  %%%%%%%%%%%%%%%%%%%%%%
</LinearTextGradient>

Usage with rn >= 0.56.0

Wait until https://github.com/facebook/react/pull/13211 will be merged or patch react-native to remove failing invariant checks

$ node node_modules/react-native-text-gradient/patch-rn.js

Caveats

When mixing several text gradients and Texts top component always should be text gradient.

<LinearTextGradient {...someGradientProps}>
  <Text>123</Text>
  qwerty
  <LinearTextGradient {...anotherGradientProps}>321</LinearTextGradient>
</LinearTextGradient>

This is necessary because only top text component is 'mapped' to actual native node and its children are 'virtual' from the native perspective.