Socket
Socket
Sign inDemoInstall

@nlazzos/react-native-skeleton

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @nlazzos/react-native-skeleton

A skeleton component for react-native and react-native-web.


Version published
Weekly downloads
206
decreased by-5.94%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

React Native Skeleton

version npm npm npm npm

React Native Skeleton is a react-native and react-native-web library to easily create a loading effect.

Installation

Step #1

Using yarn:

yarn add @nlazzos/react-native-skeleton

Using npm:

npm install @nlazzos/react-native-skeleton --save
Step #2 (Mobile Only)

Note: Only if you are using this package on react-native it requires the dependency @react-native-masked-view/masked-view for the wave animation (only available on mobile).
If your project includes the react-navigation >= 4.x you probably already have it installed and you can SKIP this step.

Using yarn:

yarn add @react-native-masked-view/masked-view

Using npm:

npm install @react-native-masked-view/masked-view --save

If you are running a react-native version below 0.60:

react-native link @react-native-masked-view/masked-view

Otherwise:

cd ios
pod install

Example

Check the following example to see it in action and try changing the default props to see how it works.

npm

Usage

You always need to wrap the skeletons with the SkeletonContainer like in the following example.

import React from 'react';
import { View, StyleSheet } from 'react-native';
import { SkeletonContainer, Skeleton } from '@nlazzos/react-native-skeleton';

const App = () => {
  return (
    <SkeletonContainer>
      <View style={styles.container}>
        <Skeleton style={styles.avatar} />
        <View style={styles.textContainer}>
          <Skeleton style={styles.title} />
          <Skeleton style={styles.subtitle} />
        </View>
        <Skeleton style={styles.icon} />
      </View>
    </SkeletonContainer>
  );
};

const styles = StyleSheet.create({
  container: { flexDirection: 'row', alignItems: 'center', marginBottom: 16 },
  avatar: { height: 40, width: 40, borderRadius: 0 },
  textContainer: { flex: 1, marginLeft: 16 },
  title: { width: '90%', height: 14, borderRadius: 7, marginBottom: 5 },
  subtitle: { width: '70%', height: 14, borderRadius: 7 },
  icon: { height: 16, width: 16, borderRadius: 4 },
});

Also you can do things like this.

import React from "react";
import { View } from "react-native";
import { SkeletonContainer, Skeleton } from "@nlazzos/react-native-skeleton";

const App = () => {
  return (
    <SkeletonContainer>
      <ListItem />
      <ListItem />
      <ListItem />
    </SkeletonContainer>
  );
};

const ListItem = () => {
  return (
    <View style={styles.container}>
      <Skeleton style={styles.avatar} />
      <View style={styles.textContainer}>
        <Skeleton style={styles.title} />
        <Skeleton style={styles.subtitle} />
      </View>
      <Skeleton style={styles.icon} />
    </View>
  );
};

const styles = StyleSheet.create({
  container: { flexDirection: 'row', alignItems: 'center', marginBottom: 16 },
  avatar: { height: 40, width: 40, borderRadius: 0 },
  textContainer: { flex: 1, marginLeft: 16 },
  title: { width: '90%', height: 14, borderRadius: 7, marginBottom: 5 },
  subtitle: { width: '70%', height: 14, borderRadius: 7 },
  icon: { height: 16, width: 16, borderRadius: 4 },
});

Properties

SkeletonContainer
PropDescriptionTypeDefault
backgroundColorDetermines the color of placeholderstring#E1E9EE
highlightColorDetermines the highlight color of placeholderstring#EDF3F7
speedDetermines the animation speed in millisecondsnumber800
animationDetermines type of animation for the skeletonswave, pulse or nonepulse

Note: The wave animaton is only available for mobile, because it makes use of the @react-native-masked-view/masked-view package.

Skeleton

Accepts any View prop.

License

MIT

Keywords

FAQs

Last updated on 08 Jan 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc