• Stars
    star
    1,607
  • Rank 29,111 (Top 0.6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A React component to easily replicate your page with nice placeholders while the content is loading

React Placeholder

A React component to easily replicate your page with nice placeholders while the content is loading. You can use a placeholder from the default set, or pass your own!

image

import ReactPlaceholder from 'react-placeholder';
import "react-placeholder/lib/reactPlaceholder.css";

React.renderComponent(
  <div>
    <ReactPlaceholder type='media' rows={7} ready={this.state.ready}>
      <MyComponent />
    </ReactPlaceholder>
  </div>,
  document.body);

Live Demo

Install

npm install --save react-placeholder

Props

children:              ReactNode;
ready:                 boolean;
delay?:                number;
firstLaunchOnly?:      boolean;
showLoadingAnimation?: boolean;
type?:                 'text' | 'media' | 'textRow' | 'rect' | 'round';
rows?:                 number;
color?:                string;
customPlaceholder?:    ReactElement;
className?:            string;
style?:                CSSProperties;

The default props will render a text placeholder with 3 rows and the color #CDCDCD.

Customization

If the built-in set of placeholders is not enough, you can pass you own through the prop "customPlaceholder"

<ReactPlaceholder ready={this.state.ready} customPlaceholder={<MyCustomPlaceholder />}>
  <MyComponent />
</ReactPlaceholder>

You can also import the built-in placeholders directly. This might be useful to use them to create your own customized placeholder:

import {TextBlock, MediaBlock, TextRow, RectShape, RoundShape} from 'react-placeholder/lib/placeholders';

const awesomePlaceholder = (
  <div className='my-awesome-placeholder'>
    <RectShape color='blue' style={{width: 30, height: 80}}/>
    <TextBlock rows={7} color='yellow'/>
  </div>
);

<ReactPlaceholder ready={this.state.ready} customPlaceholder={awesomePlaceholder}>
  <MyComponent />
</ReactPlaceholder>

Delay

You can pass an optional delay prop which specifies the time (in milliseconds) react-placeholder should wait before displaying the placeholder element. This is useful if you want to show a placeholder for slower connections while avoiding a brief "flash" on faster connections.

Note that this delay will not affect the initial render, only subsequent "ready" state changes. Setting the firstLaunchOnly prop to true will also disable this feature.

Animation

react-placeholder already comes with one default pulse animation to better tell the user that the page is loading. The animation is defined in a separate CSS file so, in order to enable it, you should import that style in your project like this:

import 'react-placeholder/lib/reactPlaceholder.css';

Once you've done this, you can simply pass the boolean prop showLoadingAnimation to tell ReactPlaceholder to animate itself:

import 'react-placeholder/lib/reactPlaceholder.css';

<ReactPlaceholder showLoadingAnimation ready={this.state.ready} type="media" rows={5}>
  <p>This is a Test.</p>
</ReactPlaceholder>

Style

you can style the placeholder by passing className or style or by using the built-in classes:

"text-block", "media-block", "text-row", "rect-shape", "round-shape".

More Repositories

1

react-autosize-textarea

A textarea perfectly compatible with ReactJS default one which auto resizes its height based on user input.
TypeScript
485
star
2

react-flexview

A powerful React component to abstract over flexbox and create any layout on any browser
TypeScript
278
star
3

react-cookie-banner

React Cookie banner which can be automatically dismissed with a scroll. Because fuck The Cookie Law, that's why.
TypeScript
182
star
4

react-components

Collection of general React components used in buildo projects.
TypeScript
158
star
5

eslint-plugin-no-loops

It's 2024 and you still use loops?
JavaScript
126
star
6

eslint-plugin-fp-ts

ESLint rules for fp-ts
TypeScript
112
star
7

bento-design-system

A customizable and extensible Design System framework for React.js projects
TypeScript
107
star
8

rc-datepicker

A decent and pretty date picker to be used with ReactJS
JavaScript
59
star
9

avenger

A CQRS-flavoured data fetching and caching layer in TypeScript. Batching, caching, data-dependencies and manual invalidations in a declarative fashion for Node and the browser
TypeScript
59
star
10

metarpheus

metarpheus is now maintained in the buildo monorepo -> https://github.com/buildo/retro
Scala
46
star
11

wiro

Wiro is a lightweight Scala library for writing HTTP routes
Scala
45
star
12

smooth-release

Replacement for `npm version` and `npm publish` with validations and CHANGELOG.md + GitHub release generation
JavaScript
34
star
13

sass-variables-loader

webpack loader for sharing variables between sass and js
JavaScript
23
star
14

terraform-aws-website

Terraform module for creating static websites hosted on S3 and served via CloudFront
HCL
19
star
15

react-input-children

InputChildren is a replacement for the base input react component capable of rendering a child (link, button ..) inside the input itself.
TypeScript
18
star
16

retro

One repo to rule them all
Scala
17
star
17

ingredients

Scala
13
star
18

docker-h2database

h2database dockerfile
Dockerfile
11
star
19

revenge

DEPRECATED use React.PureComponent and react-skinnable instead
JavaScript
11
star
20

linter-scalastyle

A scala linter for AtomLinter using scalastyle
JavaScript
8
star
21

enumero

enumero is now maintained in the buildo monorepo -> https://github.com/buildo/retro
Scala
8
star
22

trovamascherine

😷 code mirror - main development is happening in a separate, private repository for the moment
TypeScript
8
star
23

showroom

Showroom of react components used and made by buildo
TypeScript
8
star
24

trovamascherine.org

😷 code mirror - main development is happening in a separate, private repository for the moment
TypeScript
8
star
25

terraform-aws-dockercomposehost

Terraform module for creating EC2 instances with Docker and Docker Compose installed
HCL
7
star
26

metarpheus-io-ts

Generate domain models and client interpreting metarpheus output
TypeScript
7
star
27

gh-issue-mover

A friendly CLI tool to migrate GitHub and GitHub Enteprise issues
JavaScript
7
star
28

eslint-plugin-tcomb

eslint plugin to enforce conventions when using tcomb
JavaScript
6
star
29

eslint-plugin-no-copy-paste-default-export

no more copy-pasted classes with wrong display name
JavaScript
6
star
30

pubblico

Publish a markdown file as Medium post from the command line
JavaScript
6
star
31

react-avenger

Component apis for https://github.com/buildo/avenger
TypeScript
5
star
32

local-date

Replacement of Date for dealing with dates independent of time or timezone
JavaScript
5
star
33

mailo

mailo is now maintained in the buildo monorepo -> https://github.com/buildo/retro
Scala
5
star
34

rps

Rock Paper Scissors - an exercise for Scala learners
Scala
4
star
35

formo

A React form state management library
TypeScript
4
star
36

gitalias

git alias shared by the buildo team
4
star
37

scriptoni

collection of scripts for react projects @ buildo
TypeScript
4
star
38

eslint-config

buildo's eslint shared config
JavaScript
4
star
39

toctoc

toctoc is now maintained in the buildo monorepo -> https://github.com/buildo/retro
Scala
4
star
40

eslint-plugin-class-prefer-methods

eslint plugin to report not-needed usage of arrow functions instead of class methods
TypeScript
3
star
41

docker-python2.7-scikit-learn

3
star
42

ts-codemod-scripts

collection of basic JS/React codemod scripts to prepare for TS on a codebase
JavaScript
3
star
43

react-intl-hoc

hoc wrappers for react-intl components
JavaScript
2
star
44

formo-legacy

Form state management
JavaScript
2
star
45

docker-alpine-ssh

Minimal docker image that can be used as an openssh client
2
star
46

metarpheus-swagger

metarpheus interpreter producing Swagger specs
JavaScript
2
star
47

state

TypeScript
2
star
48

pronto

Pronto!
JavaScript
2
star
49

slogo

Scala library for Structured Logging
Scala
2
star
50

sbt-buildo

sbt-buildo is now maintained in the buildo monorepo -> https://github.com/buildo/retro
Scala
2
star
51

anorm-extensions

Extend anorm capabilities with the power of shapeless
Scala
2
star
52

eslint-plugin-method-names

ESLint plugin defining a single rule for checking ES6 method name conventions
JavaScript
2
star
53

tslint-no-loops

It's 2018 and you still use loops?
JavaScript
2
star
54

terraform-aws-cranehost

Terraform module for creating EC2 instances with Docker and Crane installed
HCL
1
star
55

corso-react-typescript-feb-2022

HTML
1
star
56

trello-to-gh-projects

Script to migrate PRISMA from Trello to Gh Projects
TypeScript
1
star
57

react-container

JavaScript
1
star
58

packer-ovftool

Docker image with Packer + VMware ovftool
Dockerfile
1
star
59

zes

integrates sketch, framerJs and zeplin
CoffeeScript
1
star
60

rockPaperScissorByFede

mock app to get confidence with Buildo backend stack
Scala
1
star
61

scala-sbt-alpine

Dockerfile
1
star
62

bitbar-plugins

useful bitbar plugins
JavaScript
1
star
63

corsproxy

A modified version of gr2m/CORS-Proxy that enables proxying to https URLs
JavaScript
1
star
64

docker-nginx-rdns

Nginx
1
star
65

metarpheus-tcomb

metarpheus to JS / tcomb
JavaScript
1
star
66

webseed

A starter kit for avenger-based react web apps
JavaScript
1
star
67

scala-sbt-postgresql

Shell
1
star
68

app-rpsosa

Scala
1
star
69

book

the buildo book
1
star
70

normalize-css

CSS normalizer based on [normalize.css](https://github.com/necolas/normalize.css/)
CSS
1
star
71

category-theory

a repo to group all exercises / experiments stemming from the Skillo `category-theory` course
TypeScript
1
star
72

ferio

CLI tool for making vacation visible to the team
TypeScript
1
star