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.
import { Box, Float } from '@leverui/components';
export function FloatUsage() {
return (
<Box class="float-usage-host">
<Float>
<div />
</Float>
</Box>
);
}
.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.
Props
| Prop | Default | Type | Description |
|---|---|---|---|
placement | top-end | Responsive placement value | Edge or midpoint the marker sits on. |
offsetX | — | Responsive CSS size | Move the marker left or right. |
offsetY | — | Responsive CSS size | Move the marker up or down. |
offset | 0 | Responsive CSS size | Move the marker on both axes. |
as | div | Native HTML tag | HTML tag to render. |
asChild | — | Solid render callback | Render your own element as the root. |
unstyled | false | Boolean | Turn 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.