Skip to content

cezarsmpio/react-fake-content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

59 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

react-fake-content

https://nodei.co/npm/react-fake-content.png?downloads=true&downloadRank=true&stars=true

minified + gzip npm version npm download GitHub stars GitHub issues GitHub contributors MIT license

Demo

https://cezarsmpio.github.io/react-fake-content/

Install

npm install react-fake-content --save

Usage

πŸ‘‰ React 16.8+ is required. This library uses React Hooks.

import { Circle } from 'react-fake-content';

function Avatar(props) {
    if (!props.loaded) {
        return <Circle size="40px" />
    }

    return <img src={props.url} width="40" height="40">
}

Components

βœ… All components support server-side rendering!

<Rectangle />

import { Rectangle } from 'react-fake-content';

function Component(props) {
  return <Rectangle width="400px" height="250px" />;
}

width: string - required

CSS unit to define the widht of the component.

height: string - required

CSS unit to define the height of the component.

<Circle />

import { Circle } from 'react-fake-content';

function Component(props) {
  return <Circle size="25px" />;
}

size: string - 60px

CSS unit to define either width and height of the component.

<Line />

import { Line } from 'react-fake-content';

function Component(props) {
  return (
    <CodeBlock>
      <Line width="100%" height="12px" />
      <Line width="95%" height="12px" />
      <Line width="98%" height="12px" />
      <Line width="100%" height="12px" />
      <Line width="92%" height="12px" />
    </CodeBlock>
  );
}

width: string - 100%

CSS unit to define width of the component.

height: string - 15px

CSS unit to define height of the component.

<Square />

import { Square } from 'react-fake-content';

function Component(props) {
  return <Square size="45px" />;
}

size: string - 60px

CSS unit to define either width and height of the component.

Properties

All properties below are applicable for all components.

animation: boolean - true

false to disable animation.

animationDuration: number - 1000

Number in miliseconds.

animationName: string - reactFakeContentAnimation

CSS animation name.

primaryColor: string - #efefef

CSS unit to define the primary color of the component gradient.

secondaryColor: string - #ddd

CSS unit to define the secondary color of the component gradient.

style: object - {}

A list of CSS properties to be added into the component.

as: string - div

Changes the component element to be rendered.

responsive: bool - true

The component will adapt to its container size if the value is true. Otherwise, it won't resize itself.

inline: bool - false

By default, all components are block. If you want them rendered as inline-block, use inline={true} or style={{ display: 'inline-block' }}.

Browser support

  • Chrome βœ…
  • Firefox βœ…
  • Safari βœ…
  • Opera βœ…
  • Edge 15+ βœ…
  • IE11+ βœ…
  • iOS 9+ βœ…
  • Android 5+ βœ…

Including animations!

About

Simple, easy and very customisable group of components using only CSS to generate content placeholders.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published