1.0.4 • Published 5 years ago

react-skeleton-loader v1.0.4

Weekly downloads
4,354
License
MIT
Repository
github
Last release
5 years ago

React Skeleton Loader

npm version gzip size

React Skeleton Loader is a React component designed to help you easily integrate custom animated skeletons for loading states. It best works with text elements as it adopts to the fonts size and line height of your content, but it can be easily fitted to use with other objects like images and avatars.

Demo

Click here 👌

Basic Usage

The components you create should have loading states embeded in them. You can do this however you want. You could rely on state changes, promise responses, or simply checking if the props passed aren't undefined.

import Skeleton from 'react-skeleton-loader';

const Page = (props) => {
  return(
    <div>
      <h1>props.title | <Skeleton /></h1>
      <p>props.body | <Skeleton count={5} /></p>
    </div>
  )
}

Props

PropTypeDefaultDescription
widthstring"150px"The (max) width of the element
heightstring"100%"The (max) height of your element
widthRandomnessnumber0.25Amount of width randomness
heightRandomnessnumber0Amount of height randomness
borderRadiusstring8pxborder radius of the element
colorstring#EFF1F6the background color of the element
countnumber1How many time should this be repeated
animatedbooleantrueIf it should animate

When using widthRandomness or heightRandomness the maximum width and height will be determined by width and height props. It can then only decrease. For example if widthRandomness is set to 0.25, and width is set to 100px the width will vary between 100px and 75px.

Licence

MIT