Floating Panel
Used to render a draggable, resizable panel that floats above the page content.
Usage
import { FloatingPanel } from "@chakra-ui/react"<FloatingPanel.Root>
<FloatingPanel.Trigger />
<FloatingPanel.Positioner>
<FloatingPanel.Content>
<FloatingPanel.Header>
<FloatingPanel.DragTrigger>
<FloatingPanel.Title />
</FloatingPanel.DragTrigger>
<FloatingPanel.Control>
<FloatingPanel.StageTrigger />
<FloatingPanel.CloseTrigger />
</FloatingPanel.Control>
</FloatingPanel.Header>
<FloatingPanel.Body />
<FloatingPanel.ResizeTriggers />
</FloatingPanel.Content>
</FloatingPanel.Positioner>
</FloatingPanel.Root>Shortcuts
The FloatingPanel component provides shortcuts for common use cases.
FloatingPanelResizeTriggers
The FloatingPanel.ResizeTriggers renders a FloatingPanel.ResizeTrigger for
each resize axis.
Writing this:
<FloatingPanel.ResizeTriggers />is shorthand for the following if you don't need to customize individual handles:
<FloatingPanel.ResizeTrigger axis="n" />
<FloatingPanel.ResizeTrigger axis="s" />
<FloatingPanel.ResizeTrigger axis="e" />
<FloatingPanel.ResizeTrigger axis="w" />
<FloatingPanel.ResizeTrigger axis="ne" />
<FloatingPanel.ResizeTrigger axis="nw" />
<FloatingPanel.ResizeTrigger axis="se" />
<FloatingPanel.ResizeTrigger axis="sw" />Pass the axes prop to render only specific handles:
<FloatingPanel.ResizeTriggers axes={["s", "e", "se"]} />Examples
Controlled Open
Use the open and onOpenChange props to control the visibility of the panel.
Store
An alternative way to control the floating panel is to use the RootProvider
component and the useFloatingPanel store hook.
This way you can access the panel state and methods from outside the panel.
Use RootProvider + useFloatingPanel or Root, not both.
Store
useFloatingPanel with FloatingPanel.RootProvider to access panel state and methods from outside the panel tree.Stages
Use the stage prop on FloatingPanel.StageTrigger to add buttons and
minimize, maximum and restore the panel stage. Here are the available stages:
default— restore the panel to its normal size and positionminimized— collapse the panel to a compact height (header only)maximized— expand the panel to fill the available boundary
<FloatingPanel.StageTrigger stage="minimized" />Multiple
Render multiple FloatingPanel.Root instances to show several panels at once.
Each root manages its own open state, position, and size independently.
Overlay
Use the createOverlay function to open a
floating panel programmatically from anywhere in your app. Render the overlay's
Viewport component and call .open() to show the panel.
Context
Use useFloatingPanelContext inside the panel to call minimize, maximize,
restore, setPosition, and setSize programmatically.
Disable Drag
Set draggable={false} to prevent the panel from being moved by the user.
Disable Resize
Set resizable={false} to prevent the panel from being resized by the user.
Resize Axes
Pass the axes prop to FloatingPanel.ResizeTriggers to limit which resize
handles are rendered.
Min/Max
Use the minSize and maxSize props to constrain how small or large the panel
can be resized.
Anchor Position
Use the getAnchorPosition prop to position the panel relative to the trigger
element when it opens.
Boundary
Use getBoundaryEl with allowOverflow={false} to confine the panel within a
specific container.
Drag boundary
Position
Use the position and onPositionChange props to control the panel's position
programmatically.
x: 16, y: 100
Size
Use the size and onSizeChange props to control the panel's dimensions
programmatically.
Prevent Overflow
Set allowOverflow={false} to prevent the panel from being dragged beyond the
viewport edges.
RTL
Set the dir="rtl" prop to support right-to-left layouts.
Props
Root
| Prop | Default | Type |
|---|---|---|
allowOverflow | true | booleanWhether the panel should be strictly contained within the boundary when dragging |
defaultOpen | false | booleanThe initial open state of the panel when rendered. Use when you don't need to control the open state of the panel. |
dir | 'ltr' | 'ltr' | 'rtl'The document's text/writing direction. |
draggable | true | booleanWhether the panel is draggable |
gridSize | 1 | numberThe snap grid for the panel |
lazyMount | false | booleanWhether to enable lazy mounting |
resizable | true | booleanWhether the panel is resizable |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
strategy | 'fixed' | 'absolute' | 'fixed'The strategy to use for positioning |
unmountOnExit | false | booleanWhether to unmount on exit. |
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. | |
unstyled | booleanWhether to remove the component's style. | |
closeOnEscape | booleanWhether the panel should close when the escape key is pressed | |
defaultPosition | PointThe initial position of the panel when rendered. Use when you don't need to control the position of the panel. | |
defaultSize | SizeThe default size of the panel | |
disabled | booleanWhether the panel is disabled | |
getAnchorPosition | (details: AnchorPositionDetails) => PointFunction that returns the initial position of the panel when it is opened. If provided, will be used instead of the default position. | |
getBoundaryEl | () => HTMLElement | nullThe boundary of the panel. Useful for recalculating the boundary rect when the it is resized. | |
id | stringThe unique identifier of the machine. | |
ids | Partial<{ trigger: string; positioner: string; content: string; title: string; header: string }>The ids of the elements in the floating panel. Useful for composition. | |
immediate | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
lockAspectRatio | booleanWhether the panel is locked to its aspect ratio | |
maxSize | SizeThe maximum size of the panel | |
minSize | SizeThe minimum size of the panel | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
onOpenChange | (details: OpenChangeDetails) => voidFunction called when the panel is opened or closed | |
onPositionChange | (details: PositionChangeDetails) => voidFunction called when the position of the panel changes via dragging | |
onPositionChangeEnd | (details: PositionChangeDetails) => voidFunction called when the position of the panel changes via dragging ends | |
onSizeChange | (details: SizeChangeDetails) => voidFunction called when the size of the panel changes via resizing | |
onSizeChangeEnd | (details: SizeChangeDetails) => voidFunction called when the size of the panel changes via resizing ends | |
onStageChange | (details: StageChangeDetails) => voidFunction called when the stage of the panel changes | |
open | booleanThe controlled open state of the panel | |
persistRect | booleanWhether the panel size and position should be preserved when it is closed | |
position | PointThe controlled position of the panel | |
present | booleanWhether the node is present (controlled by the user) | |
size | SizeThe size of the panel | |
translations | IntlTranslationsThe translations for the floating panel. |