Build faster with Premium Chakra UI Components 💎

Learn more
Skip to Content
DocsShowcaseBlogGuides
Sponsor

Floating Panel

Used to render a draggable, resizable panel that floats above the page content.

SourceStorybookRecipeArk
AI TipWant to skip the docs? Use our Agent Skills

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.

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 position
  • minimized — 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.

Drag the resize handles — size is clamped between min and max.

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

PropDefaultType
allowOverflow true
boolean

Whether the panel should be strictly contained within the boundary when dragging

defaultOpen false
boolean

The 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
boolean

Whether the panel is draggable

gridSize 1
number

The snap grid for the panel

lazyMount false
boolean

Whether to enable lazy mounting

resizable true
boolean

Whether the panel is resizable

skipAnimationOnMount false
boolean

Whether to allow the initial presence animation.

strategy 'fixed'
'absolute' | 'fixed'

The strategy to use for positioning

unmountOnExit false
boolean

Whether to unmount on exit.

as
React.ElementType

The underlying element to render.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
unstyled
boolean

Whether to remove the component's style.

closeOnEscape
boolean

Whether the panel should close when the escape key is pressed

defaultPosition
Point

The initial position of the panel when rendered. Use when you don't need to control the position of the panel.

defaultSize
Size

The default size of the panel

disabled
boolean

Whether the panel is disabled

getAnchorPosition
(details: AnchorPositionDetails) => Point

Function that returns the initial position of the panel when it is opened. If provided, will be used instead of the default position.

getBoundaryEl
() => HTMLElement | null

The boundary of the panel. Useful for recalculating the boundary rect when the it is resized.

id
string

The 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
boolean

Whether to synchronize the present change immediately or defer it to the next frame

lockAspectRatio
boolean

Whether the panel is locked to its aspect ratio

maxSize
Size

The maximum size of the panel

minSize
Size

The minimum size of the panel

onExitComplete
VoidFunction

Function called when the animation ends in the closed state

onOpenChange
(details: OpenChangeDetails) => void

Function called when the panel is opened or closed

onPositionChange
(details: PositionChangeDetails) => void

Function called when the position of the panel changes via dragging

onPositionChangeEnd
(details: PositionChangeDetails) => void

Function called when the position of the panel changes via dragging ends

onSizeChange
(details: SizeChangeDetails) => void

Function called when the size of the panel changes via resizing

onSizeChangeEnd
(details: SizeChangeDetails) => void

Function called when the size of the panel changes via resizing ends

onStageChange
(details: StageChangeDetails) => void

Function called when the stage of the panel changes

open
boolean

The controlled open state of the panel

persistRect
boolean

Whether the panel size and position should be preserved when it is closed

position
Point

The controlled position of the panel

present
boolean

Whether the node is present (controlled by the user)

size
Size

The size of the panel

translations
IntlTranslations

The translations for the floating panel.