Created
January 2, 2025 16:57
-
-
Save codemile/d9119fbaccc571985cd57c8278fde0d3 to your computer and use it in GitHub Desktop.
React component for displaying a loading overlay with a spinner using MUI's CircularProgress.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {CircularProgress} from '@mui/material'; | |
import {FC, PropsWithChildren} from 'react'; | |
interface PendingOverlayProps { | |
isPending: boolean; | |
} | |
export const PendingOverlay: FC<PropsWithChildren<PendingOverlayProps>> = ({ | |
isPending, | |
children | |
}) => { | |
return ( | |
<div className="relative w-full h-full"> | |
{children} | |
{isPending ? ( | |
<div className="absolute inset-0 z-10 bg-muted/50 flex justify-center items-center"> | |
<CircularProgress /> | |
</div> | |
) : null} | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment