Float
Used to anchor an element to the edge of a container.
Usage
Float requires a parent element with position: relative style applied.
import { Box, Float } from "@chakra-ui/react"<Box position="relative">
<Float>
<div />
</Float>
</Box>Examples
Placement
Use the placement prop to position the element along the edges of the
container.
bottom-end
bottom-start
top-end
top-start
bottom-center
top-center
middle-center
middle-end
middle-start
Offset X
Use the offsetX prop to offset the element along the x-axis.
Offset Y
Use the offsetY prop to offset the element along the y-axis.
Offset
Use the offset prop to offset the element along both axes.
Avatar
Here's an example of composing a Float component with an Avatar component.
Props
| Prop | Default | Type |
|---|---|---|
placement | top-end | | ConditionalValue<
| 'bottom-end'
| 'bottom-start'
| 'top-end'
| 'top-start'
| 'bottom-center'
| 'top-center'
| 'middle-center'
| 'middle-end'
| 'middle-start'
>
| undefinedThe placement of the indicator |
offsetX | SystemStyleObject['left'] | undefinedThe x offset of the indicator | |
offsetY | SystemStyleObject['top'] | undefinedThe y offset of the indicator | |
offset | SystemStyleObject['top'] | undefinedThe x and y offset of the indicator | |
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. |