1.0.6 ā€¢ Published 3 months ago

@aishwaryv/react-skeleton v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

React-Skeleton

NPM version Build npm-typescriptLicense]github-license-url

Lightweight and minimalistic Skeleton component for ReactJs šŸŽ‰

Install

npm install @aishwaryv/react-skeleton

Usage

Create a config array for the skeleton, omit the type if you are using Javscript -

import type {SkeletonConfig} from '@aishwaryv/react-skeleton';

export const Config: SkeletonConfig = [
  {
    id: 'header',
    style: {
      width: 'max-content',
      display: 'flex',
      flexDirection: 'column',
      alignItems: 'center',
      gap: '15px',
    },
    content: [
      {
        id: 'title',
        style: {
          height: '30px',
          width: '400px',
          background: '#dcdcdc',
          borderRadius: '6px',
        },
      },
      {
        id: 'description',
        style: {
          display: 'flex',
          flexDirection: 'column',
          alignItems: 'center',
          gap: '15px',
        },
        content: [
          {
            id: 'desc1',
            style: {
              height: '40px',
              width: '250px',
              background: '#dcdcdc',
              borderRadius: '6px',
            },
          },
          {
            id: 'desc2',
            style: {
              height: '40px',
              width: '200px',
              background: '#dcdcdc',
              borderRadius: '6px',
            },
          },
        ],
      },
    ],
  },
  {
    id: 'mainDescription',
    style: {
      height: '75px',
      width: '430px',
      background: '#dcdcdc',
      borderRadius: '6px',
    },
  },
];

You can then use Skeleton like any other React component, passing the config and other attributes as needed

import React from 'react';
import {Skeleton} from '@aishwaryv/react-skeleton';

import Config from "./SkeletonConfig"

function App() {
  return (
    <Skeleton
      config={Config}
      {...rest}"
    />
  );
}

export default App;

Demo

Checkout demo codesandbox here - Sandbox

Properties for the Config object

PropertyTypeDefultDescription
idStringUnique ID for every element
styleReact.CSSPropertiesStyle object which will be applied to the parent container
durationNumber1.5sDuration of the animation in seconds
contentSkeletonConfigOptional content can be passed to each element which will create theĀ skeleton-tree
1.0.6

3 months ago

1.0.3

3 months ago

1.0.2

3 months ago

1.0.1

3 months ago

1.0.0

3 months ago