@h1via/loading-button
v1.0.5
Published
A simple reusable **LoadingButton** component built with React and MUI. It extends MUI's `Button` and adds a built-in loading state with a spinner.
Readme
A simple reusable LoadingButton component built with React and MUI.
It extends MUI's Button and adds a built-in loading state with a spinner.
✨ Features
- Built on top of MUI
Button - Shows a spinner when
loadingis true - Automatically disables button while loading
- Fully supports all MUI
ButtonProps - Written in TypeScript
📦 Installation
npm install @h1via/loading-button🔧 Peer Dependencies
Make sure you have these installed in your project:
npm install react react-dom @mui/material🚀 Usage
import React from "react";
import { LoadingButton } from "@h1via/loading-button";
export default function Example() {
const [loading, setLoading] = React.useState(false);
const handleClick = () => {
setLoading(true);
setTimeout(() => setLoading(false), 2000);
};
return (
<LoadingButton
variant="contained"
color="primary"
loading={loading}
onClick={handleClick}
>
Submit
</LoadingButton>
);
}🧩 Props
| Prop | Type | Default | Description |
|----------|------------|----------|-------------|
| loading | boolean | false | Shows spinner and disables button |
All other props are inherited from MUI ButtonProps.
🛠 Built With
- React
- TypeScript
- MUI (Material UI)
📄 License
MIT © h1via
