AbsoluteCenter

Centers an element over its parent, on one axis or both, without changing the parent's layout.

Usage

The parent must have position: relative.

Code
import { AbsoluteCenter, Box } from '@leverui/components';

export function AbsoluteCenterUsage() {
  return (
    <Box class="absolute-center-usage-panel">
      <AbsoluteCenter>Centered Content</AbsoluteCenter>
    </Box>
  );
}
Code
/* absolute-center-usage.css */
.absolute-center-usage-panel {
  position: relative;
  height: 100px;
  background: var(--leverui-colors-bg-muted);
}

Examples

Axis Control

Control which axis to center on using the axis prop. Options are horizontal, vertical, or both (default).

With Content

Use AbsoluteCenter with content such as icons, badges, and status indicators.

Overlay Usage

Create a loading overlay or modal-like content centered over existing content.

RTL Support

AbsoluteCenter also centers content in right-to-left layouts.

Props

PropDefaultTypeDescription
axis'both''horizontal' | 'vertical' | 'both'Direction to center in.
asdivNative HTML tagHTML tag to render.
asChild—Render callbackRender your own element.
unstyledfalseBooleanTurn off the default position.

Style with class, style, .leverui-absolute-center, or the data-axis attribute. No css prop.