📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

react-native-js-shimmer-placeholder

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-js-shimmer-placeholder

A Shimmer using React Native Reanimated

1.0.3
Source
npm
Version published
Weekly downloads
12
200%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-js-shimmer-placeholder

Shimmering effect using react-native-reanimated, react-native-linear-gradient and react-native-masked-view

Demo

Demo of React Native JS Shimmer Placeholder

Installation

npm install react-native-js-shimmer-placeholder

or using yarn

yarn add react-native-js-shimmer-placeholder

Usage

To use shimmering effect for View

import { ViewPlaceholder } from "react-native-js-shimmer-placeholder";

<ViewPlaceholder
  show={true}
  width={100}
  height={100}
  style={{
    borderWidth: 1,
    borderColor: "lightgrey",
    borderRadius: 50,
  }}
  gradientContainerStyle={{ borderRadius: 50 }}
>
  <View
    style={{
      height: 100,
      backgroundColor: "#318fb5",
      borderRadius: 50,
      alignItems: "center",
      justifyContent: "center",
    }}
  >
    <Text style={{ fontSize: 30 }}>🚀</Text>
  </View>
</ViewPlaceholder>;

To use shimmering effect for Text

import { TextPlaceholder } from "react-native-js-shimmer-placeholder";

<TextPlaceholder
  show={true}
  textStyle={{ fontSize: 24, fontWeight: "bold" }}
  style={{
    flex: 1,
    width: "100%",
    justifyContent: "center",
    alignItems: "center",
  }}
  textColor={"#318fb5"}
>
  Hey React Native devs!
</TextPlaceholder>;

Properties

Common props for both ViewPlaceholder and TextPlaceholder

PropDescriptionDefault
baseColorThe base color of the linear gradientwhite
canTriggerAnimationCompletionConditional trigger of Animation completion (useful for lists)true
endSame as the prop used in Linear Gradient{ x: 1, y:0 }
gradientStyleStyle for the Linear Gradient itself{}
highlightColorThe highlight color for the shimmerrgba(211,211,211,0.5)
locationsSame as the prop used in Linear Gradient[0, 0.5, 1]
onAnimationCompleteTriggers on animation completionemptyFn
showWhether to show the shimmer effecttrue
startSame as the prop used in Linear Gradient{ x: 0, y:0 }
totalDurationDuration of the single shimmer cycle1500

Props only for ViewPlaceholder

PropDescriptionDefault
childrenChild to render inside placeholdernull
childrenWrapperStyleWrapper style for the children{}
styleContainer style for shimmer which wraps the Linear Gradient and the children you pass{}
gradientContainerStyleContainer style for gradient{}
heightHeight of the shimmer100%
widthWidth of the ShimmerRequired

To pass View props just pass the props as you do for a View Component

Props only for TextPlaceholder

PropDescriptionDefault
childrenText to be shimmeredundefined
styleStyle for the MaskedView{ flex:1 }
viewBehindMaskStyleChildren of MaskedView which gives the actual color for the Text{ flex:1, width:"100%" }
textStyleStyle for Text to be rendered{}
textColorText color of the children#5F717B

To pass Text Props just pass the props as you do for a Text Component

Limitation

TODO List

  • Adding support for Reanimated 2 which will solve the above mentioned limitation

Contribution

Any help to improve the module is appreciated

LICENSE

react-native-js-shimmer-placeholder is licensed under The MIT License

Keywords

react

FAQs

Package last updated on 03 Aug 2020

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