npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-skeleton-generator

v1.1.3

Published

Generate amazing and animated loading skeletons that will automate and help your work.

Downloads

992

Readme

react-skeleton-generator

Generate amazing and animated loading skeletons that will automate and help your work.

Gif of skeleton in action

Coverage reports

GitHub Logo GitHub Logo GitHub Logo GitHub Logo

Basic usage

Installed by npm/yarn with react-skeleton-generator.

import { Skeleton } from 'react-skeleton-generator';

<Skeleton.SkeletonThemeProvider>
  <Skeleton width="50px" height="50px" borderRadius="50%" /> // Simple, generated single line circle skeleton
  <Skeleton count={3} widthMultiple={['100%', '50%', '75%']} heightMultiple={['50px', '20px', '15px']} /> // Three skeleton lines
</Skeleton.SkeletonThemeProvider>

Props

Common props you may want to specify include:

  • <Skeleton.SkeletonThemeProvider />

    • Color

      color: String, defaults to #F1EFF1

      <Skeleton.SkeletonThemeProvider color="#C0C0C0" />

      The color of skeleton, the animation color will be generated automatically depending on the passed color, it can be lighter or darker (generate automatically).

    • Animation

      animation: 'opacity' | 'shimmer', defaults to 'shimmer'

      <Skeleton.SkeletonThemeProvider animation="opacity" />

      There are two types of effects, shimmer is like an wave and opacity will appear and disappear.

    • Animation Duration

      animationDuration: Number, defaults to 1

      <Skeleton.SkeletonThemeProvider animationDuration={3} />

      How long it takes do one cycle of the skeleton animation.

    • Highlight

      highlight: 'light' | 'dark' | undefined, defaults to undefined

      <Skeleton.SkeletonThemeProvider highlight="dark" />

      There are two types, if passed the light or dark value it will override the skeleton color value, and the animation color will be based on this prop (darker or lighter).

    • Style

      style: React.CSSProperties, defaults to undefined

      <Skeleton.SkeletonThemeProvider style={{ padding: '10px' }} />

      Free style when it's possible add any style here.

    • Children

      children: React.ReactNode

      <Skeleton.SkeletonThemeProvider>
        <Skeleton />
      </Skeleton.SkeletonThemeProvider>

      it will used to add the skeleton here.

    • DataTestId

      dataTestId: String, defaults to SkeletonThemeProvider

      <Skeleton.SkeletonThemeProvider dataTestId="anyTestId" />

      used for test component.

  • <Skeleton />

    • Width

    width: String, defaults to 100%

    <Skeleton width="80%" />

    Used to set the width of skeleton.

    • Height

    height: String, defaults to 30px

    <Skeleton height="500px" />

    Used to set the width of skeleton.

    • BorderRadius

    borderRadius: String, defaults to 4px

    <Skeleton borderRadius="10px" />

    Used to set the borderRadius of skeleton.

    • Count

    count: Number, defaults to 1

    <Skeleton count={3} />

    Used to set how many lines will be generate.

    • SpaceBetween

    spaceBetween: String, defaults to 10px

    <Skeleton spaceBetween="20px" />

    Used to set the space that will be generate each lines if count > 1

    • WidthMultiple

    widthMultiple: String, defaults to undefined

    <Skeleton widthMultiple=["100px", "200px", "300px"] />

    Used to set the width for each skeleton if count > 1

    • HeightMultiple

    heightMultiple: String, defaults to undefined

    <Skeleton heightMultiple=["100px", "200px", "300px"] />

    Used to set the height for each skeleton if count > 1

    • DataTestId

      dataTestId: String, defaults to Skeleton

      <Skeleton dataTestId="anyTestId" />

      used for test component.

      Used to set the width of skeleton.

Example

react-skeleton-generator need zero configuration, it is only install and use.

To generate an skeleton loader like the image below, here is an example for you:

GitHub Logo

import { Skeleton } from 'react-skeleton-generator';

<Skeleton.SkeletonThemeProvider>
  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
    <Skeleton
      width="50px"
      height="50px"
      borderRadius="50%"
    />

    <div style={{ width: '400px' }}>
      <Skeleton
        borderRadius="10px"
        count={3}
        widthMultiple={['100%', '50%', '75%']}
        heightMultiple={['50px', '20px', '15px']}
      />
    </div>
  </div>

  <div style={{ marginTop: '20px' }}>
    <Skeleton
      borderRadius="10px"
      count={3}
      widthMultiple={['100%', '100%', '80%']}
      heightMultiple={['20px', '20px', '20px']}
    />
  </div>

  <div style={{ display: 'flex', justifyContent: 'space-between', marginTop: '30px' }}>
    <Skeleton
      width="48%"
      height="50px"
      borderRadius="10px"
      />

    <Skeleton
      width="48%"
      height="50px"
      borderRadius="10px"
    />
  </div>
</Skeleton.SkeletonThemeProvider>

License

MIT