React loaing component.
$ npm install react-loading-ui
Live Demo CodeSandbox
- Set the default settings (optional).
- To use, just call the
Loading()
function.
Note: The
Loading()
function toggle between hide and show.
import React, { Component } from 'react';
import { Loading } from 'react-loading-ui'
class App extends Component {
saveForm() {
/* Show loading-ui */
Loading();
fetch(url, requestOptions)
.then((response) => {
if (response.ok) {
return response.json();
}
/* Hide loading-ui */
Loading();
});
}
render() {
return (
<div>
<button type="button" onClick={(e) => this.saveForm()}>Save Form</button>
</div>
)
}
}
export default App;
You can set the component settings for your entire application or whenever you call Loading({settings})
.
SetDefault({
/* Loading title */
title: "",
/* Loading text */
text: "",
/* Show progress bar */
progress: false,
/* Close the loading when progress is over */
progressedClose: false,
/* Default theme [light|dark] */
theme: "light",
});
Loading()
preview with light color theme.
Loading({ progress: true })
preview with light color theme.
With the Progress(progress)
function you can ensure the loading progress, see the demo.
If you want to customize the styles, you can use the following classNames:
- loading-ui-overlay
- loading-ui-body
- loading-ui-title
- loading-ui-text
- loading-ui-spinner
- loading-ui-progress-bar
Barış Ateş