AbsoluteCenter
Used to horizontally and vertically center an element relative to its parent dimensions using absolute positioning.
Usage
The AbsoluteCenter component uses the position: absolute strategy to center
its child element relative to its parent.
The parent element must have position: relative for proper positioning.
import { AbsoluteCenter } from "@chakra-ui/react"<Box position="relative" h="100px">
<AbsoluteCenter>Centered Content</AbsoluteCenter>
</Box>Examples
Axis Control
Control which axis to center on using the axis prop. Options are horizontal,
vertical, or both (default).
<AbsoluteCenter axis="horizontal" />
<AbsoluteCenter axis="vertical" />
<AbsoluteCenter axis="both" />
With Content
Use AbsoluteCenter with various content types like icons, badges, and status
indicators.
Overlay Usage
Perfect for creating loading overlays or modal-like content that needs to be centered over existing content.
Loading...
RTL Support
AbsoluteCenter automatically handles right-to-left (RTL) layouts by adjusting
the horizontal positioning and transforms appropriately.
RTL (horizontal)
RTL (vertical)
RTL (both)
Props
| Prop | Default | Type |
|---|---|---|
axis | 'horizontal' | 'vertical' | 'both' | undefined | |
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |