Skip to the content.

Picload

NPM JavaScript Style Guide

Make the wait sweeter for the user

When your website’s photos are loading, what is displayed instead? If your answer is “nothing” I must say this is a disaster! Because this may bore the user and leave a bad ui & ux for you.
what’s the solution?
Turns out, use Picload . In fact, before loading images, Picload renders things instead to make your ui more beautiful and increase user patience.
Now you know what Picload does?
Add this library to your React project and enjoy

Docs

Install

Install Picload with npm

  npm i picload
  import Picload from 'picload'

Example Usage

After installation, import it and take advantage of its capabilities

import Picload from 'picload'
import myPicture from './images/picture.png'
import myPicture_min from './images/picture_min.png'

const App = () => {
  return (
    <div style=>
      <Picload src={myPicture} placeholder={myPicture_min} alt='picture' className='my-image'/>
    </div>
  )
};

export default App;

options

const App = () => { return( <div> <Picload src={Mountain} placeholder={Mountin_min} /> </div> ) };

export default App;

<hr>

- <h3>Random color</h3>
> _randomColor : 'color'_

Before loading images, place a random color in the selected range (dark & light & any) instead of the image <br>
The randomColor value should be the color range you want

- **usage** <br>
```jsx
const myConfig = {
    randomColor: 'dark'
}
<Picload src={Lorem} config={myConfig} />
// or
<Picload src={Lorem} config= />

NOTE: All options and settings of this library must be set in the (config) prop. except placeholder


Instead of choosing a random color, choose what color to display before the image is loaded

<Picload src={linux} config= />


<hr>

- <h3>Progress</h3>
> _progress : 'progress type'_

Beautiful animations, before the image is loaded

- **usage** <br>
First you need to import the css file of the animation you want
```jsx
import "picload/dist/progress-ripple.css"

Now you can use it

<Picload src={linux} config= />
Name Relevant css file
circles picload/dist/progress-circles.css
ring picload/dist/progress-ring.css
ripple picload/dist/progress-ripple.css
spinner picload/dist/progress-spinner.css
roller picload/dist/progress-roller.css

You can set the color of progress

const myConfig = {
  progress: 'spinner',
  progressColor: '#f1f1f1'
}
<Picload src={myImage} config={myConfig} />

You can set the background color of progress

const myConfig = {
  progress: 'spinner',
  progressColor: '#f1f1f1',
  progressBg: '#0d1117',
}
<Picload src={myImage} config={myConfig} />

you can style your progress. For example, you want to make it a little bigger:

const myConfig = {
  progress: 'spinner',
  progressColor: '#f1f1f1',
  progressBg: '#0d1117',
  progressStyle: {
    transform: 'scale(1.2)'
  }
}
<Picload src={myImage} config={myConfig} />

Can we add custom progress we made ourselves?
Definitely yes! Just import that component and pass it to progress (in config)

import myProgress from './myProgress'
const myConfig = {
  progress: <myProgress />;
}
<Picload src={Mountain} config={myConfig}/>

Basic attributes

In picload, it is possible to use all basic attributes. These attributes are appended directly to the (img)

You do not need to define this basic information in (config)

<Picload ... style={ {transform: 'rotate(5deg)'} } />

<Picload ... className='fw-bold bg-danger' />

<Picload ... alt='image alt' />

const myImg = React.useRef(null)

<Picload ... cref={myImg} />

<Picload ... loading='lazy' />