1.0.6 • Published 1 year ago

suspense-overlay-wts v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Suspense, which shows the fallback on top of previous content.

demo

Example

import Suspense from "suspense-overlay";

export default function App() {
  return <Suspense fallback="loading...">...</Suspense>;
}

With MUI Backdrop

mui-backdrop

import { alpha, Backdrop, Box, CircularProgress } from "@mui/material";
import { SuspenseOverlayCore } from "suspense-overlay";

export default function MuiBackdropSuspense({ children }) {
  return (
    <Box sx={{ position: "relative", display: "grid" }}>
      <SuspenseOverlayCore
        fallback={
          <Backdrop
            sx={{
              position: "relative",
              gridArea: "1 / 1",
              backgroundColor: (theme) =>
                alpha(theme.palette.background.paper, 0.5),
            }}
          >
            <CircularProgress />
          </Backdrop>
        }
      >
        <Box sx={{ gridArea: "1 / 1" }}>{children}</Box>
      </SuspenseOverlayCore>
    </Box>
  );
}

<Suspense>

Props

NameDescription
childrenAs in React.Suspense
fallbackAs in React.Suspense

Optional

NameTypeDefault valueDescription
BackdropReact.ElementTypestyled divA Component that wraps and centers fallback
ChildrenWrapperReact.ElementTypecontained: styled div contained=false: divA Component that wraps children
ContainerReact.ElementTypecontained: styled div contained=false: undefinedA Component that wraps SuspenseOverlayCore
FallbackReact.ElementTypeFallbackReact Transition Group / CSSTransition
containedbooleantrueSet false to show a fullscreen/uncontained overlay
fullscreenContainerstring \| HTMLElementdocument.bodyA default value for container. Used also to apply different styles.
containerstring \| HTMLElementfullscreenContainerA query selector for an element or a reference to an element that the fullscreen/uncontained Backdrop & fallback is rendered to
containedbooleantrueSet false to show a fullscreen overlay

see Fallback.tsx for more overrides and details.

<SuspenseOverlayCore>

Props

NameTypeDefault valueDescription
childrenReact.ReactElement-As in React.Suspense. Must also be a valid argument for React.cloneElement and forward ref to the outermost DOM element.
fallbackReact.ReactElement-As in React.Suspense. Must also be a valid argument for React.cloneElement.
inProp?string"open"A prop name of a boolean that the fallback should use to be visible or hidden
1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago