React Native Linear Gradient

2.8.3 · active · verified Sun Apr 19

react-native-linear-gradient provides a highly performant `<LinearGradient>` component for React Native applications, allowing developers to easily render linear color gradients. It leverages native modules for both iOS and Android to ensure smooth performance and integration, making it a staple for UI enhancements. The current stable version is 2.8.3, with version 3.0.0 actively under development (currently in beta), which introduces support for React Native's New Architecture. The project maintains a steady release cadence, addressing bugs and adding features, with major versions typically focusing on compatibility with newer React Native architectures and platforms. Its primary differentiation is its native implementation, offering better performance compared to JavaScript-only solutions for gradients.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates a basic usage of LinearGradient component with multiple colors, custom start/end points, and embedded text, styled within a React Native view.

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';

const App = () => {
  return (
    <View style={styles.container}>
      <LinearGradient
        colors={['#4c669f', '#3b5998', '#192f6a']}
        style={styles.linearGradient}
        start={{ x: 0, y: 0 }}
        end={{ x: 1, y: 1 }}
      >
        <Text style={styles.buttonText}>
          Sign in with Facebook
        </Text>
      </LinearGradient>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#F5FCFF',
  },
  linearGradient: {
    flex: 1,
    paddingLeft: 15,
    paddingRight: 15,
    borderRadius: 5,
    width: '80%',
    justifyContent: 'center',
    alignItems: 'center',
  },
  buttonText: {
    fontSize: 18,
    fontFamily: 'Gill Sans',
    textAlign: 'center',
    margin: 10,
    color: '#ffffff',
    backgroundColor: 'transparent',
  },
});

export default App;

view raw JSON →