A very simple, highly customisable react top loader component.
npm install @weblif/react-top-loading-bar- using npm
``bash`
npm install --save @weblif/react-top-loading-bar
- using yarn
`bash`
yarn add @weblif/react-top-loading-bar
`jsx
import React, { useRef } from 'react'
import LoadingBar from '@weblif/react-top-loading-bar'
const App = () => {
const ref = useRef(null)
return (
export default App
`
`jsx
import React, { useState } from 'react'
import LoadingBar from '@weblif/react-top-loading-bar'
const App = () => {
const [progress, setProgress] = useState(0)
return (
export default App
`
| Methods | Parameters | Descriptions |
| ------------------------------------------- | :---------------------------------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| add(value) | Number | Adds a value to the loading indicator. |
| decrease(value) | Number | Decreases a value to the loading indicator. |
| continuousStart(startingValue, refreshRate) | Number (optional), Number(optional) | Starts the loading indicator with a random starting value between 20-30, then repetitively after an refreshRate, increases it by a random value between 2-10. This continues until it reaches 90% of the indicator's width. |
| staticStart(startingValue) | Number (optional) | Starts the loading indicator with a random starting value between 30-50. |
| complete() | | Makes the loading indicator reach 100% of his width and then fade. |
| Property | Type | Default | Description |
| :----------------- | :------------ | :------ | :-------------------------------------------------------------------------------------------------------------------------------- |
| progress | Number | 0 | The progress/width indicator, progress prop varies from 0 to 100. |red
| color | String | | The color of the loading bar, color take values like css property background: do, for example red, #000 rgb(255,0,0) etc. |true
| shadow | Boolean | | Enables / Disables shadow underneath the loader. |2
| height | Number | | The height of the loading bar in pixels. |3
| background | String | | The loader parent background color. |300
| style | CSSProperties | | The style attribute to loader's div |
| containerStyle | CSSProperties | | The style attribute to loader's container |
| shadowStyle | CSSProperties | | The style attribute to loader's shadow |
| transitionTime | Number | | Fade transition time in miliseconds. |500
| loaderSpeed | Number | | Loader transition speed in miliseconds. |1000` | The delay we wait when bar reaches 100% before we proceed fading the loader out. |
| waitingTime | Number |
| className | String | | You can provide a class you'd like to add to the loading bar to add some styles to it |
| containerClassName | String | | You can provide a class you'd like to add to the loading bar container to add some css styles |
| onLoaderFinished | Function | | This is called when the loading bar completes, reaches 100% of his width. |
MIT