Ridiculously Simple and Lightweight Placeholders
To use PlaceholderJS with React or any React framework, simply install via NPM or your preferred package manager:
npm i placeholder
yarn add placeholder
pnpm add placeholder
Next, import the package:
import {Placeholder} from 'placeholder';
import { Placeholder } from "placeholder";
<Placeholder width="500" height="500" />
Required
Specify the size of the placeholder image by adding the width and height to the component. Example:
<Placeholder width="500" height="500"/>
Optional
Specify custom text in the placeholder image by adding your text. Example:
<Placeholder width="500" height="500" text="Hello World!"/>
Optional
Specify the text color by adding color=
to the component. We support HEX values or named values (e.g., white).
Example:
<Placeholder width="500" height="500" text="Hello World!" color="#fff"/>
Optional
Specify the background color by adding background=
to the component. We support HEX values or named values (e.g.,
white). Example:
<Placeholder width="500" height="500" background="#000"/>
To use PlaceholderJS via the CDN for simplicity and/or compatibility with non-JS tools, you can use the scheme:
https://placeholderjs.com/HEIGHTxWIDTH
All image placeholders must have a height and width defined.
Required
Specify the size of the placeholder image by adding the width and height to the URL. Example:
https://placeholderjs.com/500x500
Optional
Specify custom text in the placeholder image by adding your text to the URL. Use a +
character for spaces. Example:
https://placeholderjs.com/500x500&text=Hello+World!
Optional
Specify the text color by adding color=
to the URL. We support HEX values or named values (e.g., white). Since we
can't use #
for the color code, use an underscore _
before the HEX code. Example:
https://placeholderjs.com/500x500&text=Hello+World!&color=_fff
Optional
Specify the background color by adding background=
to the URL. We support HEX values or named values (e.g., white).
Since we can't use #
for the color code, use an underscore _
before the HEX code. Example:
https://placeholderjs.com/500x500&background=_000