Lightweight JavaScript loading spinner for HTML, React, Vue and Node applications.
A lightweight, dependency-free JavaScript loading indicator that works for both full-page overlays and specific HTML elements.
npm install @softon/loaderimport Loader from "@softon/loader";- π Pure JavaScript (No dependencies)
- π¨ Customizable spinner size and color
- π Optional overlay background
- π¦ Lightweight and reusable
- π₯οΈ Full-page loading indicator
- π Element-specific loading indicator
- β‘ Easy to integrate with Fetch, Axios, jQuery, or any JavaScript project
<script src="https://cdn.jsdelivr.net/npm/@softon/loader/dist/loader.min.js"></script>Download loader.js and include it in your project.
<script src="loader.js"></script>Loader.show();
setTimeout(() => {
Loader.hide();
}, 2000);<div id="content">
Loading content...
</div>Loader.show({
targetId: "content"
});
setTimeout(() => {
Loader.hide("content");
}, 2000);Loader.show({
targetId: "content",
size: 60,
color: "green",
overlay: true,
background: "rgba(255,255,255,0.6)"
});Displays a loading spinner.
| Option | Type | Default | Description |
|---|---|---|---|
targetId |
String | null |
ID of the target element. If omitted, a full-page loader is shown. |
size |
Number | 40 |
Spinner size in pixels. |
color |
String | "#0d6efd" |
Spinner color. |
overlay |
Boolean | true |
Show or hide the overlay background. |
background |
String | "rgba(255,255,255,.5)" |
Overlay background color. |
Example:
Loader.show({
color: "red",
size: 50
});Hides the loader.
Loader.hide();Loader.hide("content");Loader.show();
axios.get("/api/users")
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
})
.finally(() => {
Loader.hide();
});Loader.show({
targetId: "content"
});
fetch("/api/users")
.then(response => response.json())
.then(data => {
console.log(data);
})
.finally(() => {
Loader.hide("content");
});- Chrome
- Edge
- Firefox
- Safari
- Opera
MIT License
Feel free to use, modify, and distribute this project.
Contributions, bug reports, and feature requests are welcome.
If you find an issue or have an idea for improvement, please open an issue or submit a pull request.
Developed and maintained by LNT Softwares.