Skip to content

Instantly share code, notes, and snippets.

@codemile
Created January 2, 2025 16:57
Show Gist options
  • Save codemile/d9119fbaccc571985cd57c8278fde0d3 to your computer and use it in GitHub Desktop.
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.
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