Float

Pins an element to an edge or corner of its parent, such as a count on an avatar.

Usage

The parent must have position: relative.

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

export function FloatUsage() {
  return (
    <Box class="float-usage-host">
      <Float>
        <div />
      </Float>
    </Box>
  );
}
Code
.float-usage-host {
  position: relative;
  width: 80px;
  height: 80px;
}

Examples

Placement

Position the marker along a container edge.

bottom-end

bottom-start

top-end

top-start

bottom-center

top-center

middle-center

middle-end

middle-start

Offset X

Use offsetX to move the marker horizontally.

Offset Y

Use offsetY to move the marker vertically.

Offset

Use offset to move the marker on both axes.

Avatar

Compose Float with an Avatar status badge.

New

Props

PropDefaultTypeDescription
placementtop-endResponsive placement valueEdge or midpoint the marker sits on.
offsetX—Responsive CSS sizeMove the marker left or right.
offsetY—Responsive CSS sizeMove the marker up or down.
offset0Responsive CSS sizeMove the marker on both axes.
asdivNative HTML tagHTML tag to render.
asChild—Solid render callbackRender your own element as the root.
unstyledfalseBooleanTurn off the Lever UI styles.

placement joins top, middle, or bottom with start, center, or end, as in top-end. start and end swap sides in right-to-left text.

Override the offsets with --leverui-float-offset-x and --leverui-float-offset-y in your own class.

If a floating badge conveys a state, give that state a text label for screen readers, and hide repeated visual text from them.