File size: 1,123 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
---
title: Float
description: Used to anchor an element to the edge of a container.
links:
source: components/float
storybook: components-float--basic
---
<ExampleTabs name="float-basic" />
## Usage
Float requires a parent element with `position: relative` style applied.
```jsx
import { Box, Float } from "@chakra-ui/react"
```
```jsx
<Box position="relative">
<Float>
<div />
</Float>
</Box>
```
## Examples
### Placement
Use the `placement` prop to position the element along the edges of the
container.
<ExampleTabs name="float-with-placements" />
### Offset X
Use the `offsetX` prop to offset the element along the x-axis.
<ExampleTabs name="float-with-offset-x" />
### Offset Y
Use the `offsetY` prop to offset the element along the y-axis.
<ExampleTabs name="float-with-offset-y" />
### Offset
Use the `offset` prop to offset the element along both axes.
<ExampleTabs name="float-with-offset" />
### Avatar
Here's an example of composing a `Float` component with an `Avatar` component.
<ExampleTabs name="float-with-avatar" />
## Props
<PropTable component="Float" part="Float" />
|