2.0.1 • Published 8 months ago

@aishwaryv/react-skeleton v2.0.1

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

React-Skeleton

NPM version Build npm-typescript License

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 {SkeletonTree} from '@aishwaryv/react-skeleton';

export const Config: SkeletonTree = [
  {
    name: 'container',
    // 💡 You can also use className instead of passing styles directly
    style: {
      height: 'max-content',
      width: '25rem',
      display: 'flex',
      flexDirection: 'column',
      gap: '2rem',
    },
    nodes: [
      {
        name: 'header',
        nodes: [
          {
            name: 'title',
            style: {
              height: '2rem',
              width: '10rem',
              borderRadius: '0.5rem',
            },
          },
          {
            name: 'subtitle',
            style: {
              height: '1rem',
              width: '50%',
              borderRadius: '0.25rem',
              marginTop: '0.5rem',
            },
          },
        ],
      },
      {
        name: 'form',
        style: {
          display: 'flex',
          flexDirection: 'column',
          gap: '1rem',
        },
        nodes: [
          {
            name: 'input-box-1',
            style: {
              height: '4rem',
              width: '100%',
              borderRadius: '0.5rem',
            },
          },
          {
            name: 'input-box-2',
            style: {
              height: '4rem',
              width: '100%',
              borderRadius: '0.5rem',
            },
          },
          {
            name: 'button',
            style: {
              height: '2rem',
              width: '100%',
              borderRadius: '0.5rem',
              marginTop: '1rem',
            },
          },
        ],
      },
    ],
  },
];

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

import React from 'react';

import {Skeleton} from '../../Skeleton';
import {Config} from './SkeletonConfig';

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

export default App;

Demo

Checkout demo code sandbox here - Sandbox

Properties for the Config object

PropertyTypeOptionalDefaultDescription
nameStringYesUnique name for each element
durationNumberYes1.8Duration of the animation in seconds
nodesSkeletonTreeYesNested content, which creates additional skeleton elements within the node
2.0.1

8 months ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.7

1 year ago

1.0.6

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago