Skip to Content

LoadingOverlay

Display an overlay with a centered loader over the parent element.

Import

import { LoadingOverlay } from '@tidbcloud/uikit'

Basic Usage

Renders an overlay with a loader over the parent element with position: relative.

import { useDisclosure } from '@tidbcloud/uikit-hooks' import { LoadingOverlay, Button, Group, Box } from '@tidbcloud/uikit' function Demo() { const [visible, { toggle }] = useDisclosure(false) return ( <> <Box pos="relative"> <LoadingOverlay visible={visible} zIndex={1000} overlayProps={{ radius: 'sm', blur: 2 }} /> {/* ...other content */} </Box> <Group justify="center"> <Button onClick={toggle}>Toggle overlay</Button> </Group> </> ) }

Loader Props

Customize the loader using loaderProps.

import { LoadingOverlay, Box } from '@tidbcloud/uikit' function Demo() { return ( <Box pos="relative"> <LoadingOverlay visible={true} zIndex={1000} overlayProps={{ radius: 'sm', blur: 2 }} loaderProps={{ color: 'pink', type: 'bars' }} /> {/* ...content */} </Box> ) }

Custom Loader Content

Replace the default loader with custom content.

import { LoadingOverlay, Box } from '@tidbcloud/uikit' function Demo() { return ( <Box pos="relative"> <LoadingOverlay visible={true} loaderProps={{ children: 'Loading...' }} /> {/* ...content */} </Box> ) }

Key Props

PropTypeDescription
visiblebooleanControls overlay visibility
zIndexnumber | stringOverlay z-index
loaderPropsLoaderPropsProps passed to Loader component
overlayPropsOverlayPropsProps passed to Overlay component
transitionPropsTransitionPropsProps passed to Transition component
Last updated on