Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-gradient-shimmer

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-gradient-shimmer

⚛ A pure JavaScript, performant, typed shimmer component for Android and iOS.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
179
decreased by-45.26%
Maintainers
1
Weekly downloads
 
Created
Source

React-Native Gradient Shimmer

License MIT npm version npm downloads

⚛ A pure JavaScript, performant, typed shimmer component for Android, iOS and Web.

It uses React Native Animated API for animation, and expo-linear-gradient or react-native-linear-gradient for the gradient effect.

Take a look at the Online demo.

AndroidiOSWeb

Requirements

Install

Install dependency package

yarn add react-native-gradient-shimmer

Or

npm i -S react-native-gradient-shimmer

Basic usage

Render the GradientShimmer directly:

import LinearGradient from 'react-native-linear-gradient'; // or 'expo-linear-gradient'
import GradientShimmer from 'react-native-gradient-shimmer';

const App = () => {
   return (
      <SafeAreaView style={{flex: 1}}>
         <GradientShimmer
            LinearGradientComponent={LinearGradient}
            backgroundColor="red"
            highlightColor="blue"
            height={120}
            width={120}
            style={{
              borderRadius: 60,
              margin: 8,
            }}
         />
      </SafeAreaView>
   );
}

export default App;

Or create your own GradientShimmer instance with default props:

import LinearGradient from 'react-native-linear-gradient'; // or 'expo-linear-gradient'
import {createGradientShimmer} from 'react-native-gradient-shimmer';

const CustomGradientShimmer = createGradientShimmer({
  backgroundColor: 'red',
  highlightColor: 'blue',
  LinearGradientComponent: LinearGradient,
})

const App = () => {
   return (
      <SafeAreaView style={{flex: 1}}>
         <CustomGradientShimmer
            height={120}
            width={120}
            style={{
              borderRadius: 60,
              margin: 8,
            }}
         />
      </SafeAreaView>
   );
}

export default App;

See more in the Sample project.

Shimmer layout

For more complex layouts, you can use the ShimmerLayout component.

import LinearGradient from 'react-native-linear-gradient'; // or 'expo-linear-gradient'
import {ShimmerLayout} from 'react-native-gradient-shimmer';

const layoutExample: ShimmerLayoutContainerType = {
   content: [
      {
         flexDirection: 'row',
         content: [
            {
               height: 150,
               width: 100,
               marginRight: 16,
            },
            {
               justifyContent: 'space-between',
               content: [
               {
                  height: 40,
                  width: 250,
               },
               {
                  height: 40,
                  width: 250,
               },
               {
                  height: 40,
                  width: 120,
               },
               ],
            },
         ],
      },
      // ....
   ],
};

const App = () => {
   return (
      <SafeAreaView style={{flex: 1}}>
         <ShimmerLayout
            LinearGradientComponent={LinearGradient}
            layout={layoutExample}
         />
      </SafeAreaView>
   );
}

export default App;

See more in the Sample project.

Props and types

GradientShimmer props

NameTypeDefaultDescription
LinearGradientComponentComponentTypeLinear gradient component from expo-linear-gradient or react-native-linear-gradient
widthnumberComponent width in DPI
heightnumberComponent height in DPI
backgroundColorstring'rgb(200,200,200)'Background color in HEX or RGB
highlightColorstring'rgb(210,210,210)'Highlight color in HEX or RGB
highlightWidthnumber200The size of the highlight effect in DPI
durationnumber1500Duration of the animation in milliseconds
animatingbooleantrueStart or stop the animation
easing(value: number) => numberEasing.linearEasing function used by Animated.timing() to convey physically believable motion in animations. Read more at https://reactnative.dev/docs/easing
styleViewStyleStyles passed to the LinearGradient component

ShimmerLayout props

Inherits GradientShimmer props

NameTypeDescription
layoutShimmerLayoutContainerTypeLayout config tree

ShimmerLayoutContainerType

NameTypeDescription
flexDirection'row' | 'column' | 'row-reverse' | 'column-reverse' | undefinedFlexBox flexDirection
alignItemsFlexAlignTypeFlexBox alignItems
justifyContentFlexAlignTypeFlexBox justifyContent
contentArray<ShimmerLayoutItemType | ShimmerLayoutContainerType>Children content layout

ShimmerLayoutItemType

NameTypeDescription
widthnumberItem width in DPI
heightnumberItem height in DPI

Contribute

New features, bug fixes and improvements are welcome! For questions and suggestions use the issues.

Become a Patron! Donate

Star History

Star History Chart

License

The MIT License (MIT)

Copyright (c) 2023 Douglas Nassif Roma Junior

See the full license file.

Keywords

FAQs

Package last updated on 11 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc