Floating Panel

Used to display content in a non-modal floating window.

Loading...

Anatomy

<FloatingPanel.Root>
  <FloatingPanel.Trigger />
  <FloatingPanel.Positioner>
    <FloatingPanel.Content>
      <FloatingPanel.DragTrigger>
        <FloatingPanel.Header>
          <FloatingPanel.Title />
          <FloatingPanel.Control>
            <FloatingPanel.StageTrigger />
            <FloatingPanel.CloseTrigger />
          </FloatingPanel.Control>
        </FloatingPanel.Header>
      </FloatingPanel.DragTrigger>
      <FloatingPanel.Body />
      <FloatingPanel.ResizeTrigger />
    </FloatingPanel.Content>
  </FloatingPanel.Positioner>
</FloatingPanel.Root>

Examples

Controlled size

Use size and onSizeChange to control the size.

Controlled position

Use position and onPositionChange to control the position.

Anchor Position

Use getAnchorPosition to compute the initial position. It runs on open and receives triggerRect and boundaryRect.

Open State

Use open and onOpenChange to control the open state.

Lazy Mount

Set lazyMount to render the panel only when first opened.

Context

Use FloatingPanel.Context or the useFloatingPanelContext hook to access the panel's state.

API Reference

Props

Root

PropDefaultType
allowOverflowtrue
boolean

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

closeOnEscape
boolean

Whether the panel should close when the escape key is pressed

defaultOpenfalse
boolean

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

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

dir'ltr'
'ltr' | 'rtl'

The document's text/writing direction.

disabled
boolean

Whether the panel is disabled

draggabletrue
boolean

Whether the panel is draggable

finalFocusEl
() => HTMLElement | null

Element to receive focus when the panel is closed. By default, the trigger element is focused.

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.

gridSize1
number

The snap grid for the panel

hideMode'display-none'
HideMode

How to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+.

id
string

The unique identifier of the machine.

ids
ElementIds

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

initialFocusEl
() => false | HTMLElement | null

Element to receive focus when the panel is opened. Defaults to the panel content. Return `false` to skip moving focus, or `null` to use the default.

lazyMountfalse
boolean

Whether to enable lazy mounting

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

onEnterComplete
VoidFunction

Function called when the animation ends in the open state

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)

resizabletrue
boolean

Whether the panel is resizable

restoreFocustrue
boolean

Whether to restore focus to the trigger when the panel is closed.

size
Size

The size of the panel

skipAnimationOnMountfalse
boolean

Whether to allow the initial presence animation.

strategy'fixed'
'absolute' | 'fixed'

The strategy to use for positioning

translations
IntlTranslations

The translations for the floating panel.

unmountOnExitfalse
boolean

Whether to unmount on exit.

Body

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-floating-panel-body]<uid>
[data-dragging]Present when in the dragging state
[data-minimized]Present when minimized
[data-maximized]Present when maximized
[data-staged]Present when not in default stage

CloseTrigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

Content

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FloatingPanelContentState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-floating-panel-content]<uid>
[data-state]"open" | "closed"
[data-dragging]Present when in the dragging state
[data-topmost]Present when topmost
[data-behind]Present when not topmost
[data-minimized]Present when minimized
[data-maximized]Present when maximized
[data-staged]Present when not in default stage

Control

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FloatingPanelControlState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-floating-panel-control]<uid>
[data-disabled]Present when disabled
[data-stage]The stage of the control
[data-minimized]Present when minimized
[data-maximized]Present when maximized
[data-staged]Present when not in default stage

DragTrigger

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-floating-panel-drag-trigger]<uid>
[data-disabled]Present when disabled

Header

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-floating-panel-header]<uid>
[data-dragging]Present when in the dragging state
[data-topmost]Present when topmost
[data-behind]Present when not topmost
[data-minimized]Present when minimized
[data-maximized]Present when maximized
[data-staged]Present when not in default stage

Positioner

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

CSS VariableDescription
--widthThe width of the element
--heightThe height of the element
--xThe x position for transform
--yThe y position for transform
--layer-indexThe index of the panel in the panel stack

ResizeTrigger

Defines the <div> element.

AttributeDefaultType
placement
CompassDirection

The placement of the resize handle

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
type ONLY_FOR_FORMAT = ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FloatingPanelResizeTriggerState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-floating-panel-resize-trigger]<uid>
[data-disabled]Present when disabled
[data-placement]The placement of the resizetrigger

RootProvider

PropDefaultType
value
UseFloatingPanelReturn

hideMode'display-none'
HideMode

How to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+.

immediate
boolean

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

lazyMountfalse
boolean

Whether to enable lazy mounting

onEnterComplete
VoidFunction

Function called when the animation ends in the open state

onExitComplete
VoidFunction

Function called when the animation ends in the closed state

skipAnimationOnMountfalse
boolean

Whether to allow the initial presence animation.

unmountOnExitfalse
boolean

Whether to unmount on exit.

StageTrigger

Defines the <button> element.

AttributeDefaultType
stage
Stage

The stage of the panel

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
type ONLY_FOR_FORMAT = ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FloatingPanelStageTriggerState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-floating-panel-stage-trigger]<uid>
[data-stage]The stage of the stagetrigger

Title

Defines the <h2> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

Trigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<FloatingPanelTriggerState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-floating-panel-trigger]<uid>
[data-state]"open" | "closed"
[data-dragging]Present when in the dragging state

Context

API

PropertyType
open
boolean

Whether the panel is open

setOpen
(open: boolean, reason?: OpenChangeReason) => void

Function to open or close the panel

dragging
boolean

Whether the panel is being dragged

resizing
boolean

Whether the panel is being resized

position
Point

The position of the panel

setPosition
(position: Point) => void

Function to set the position of the panel

size
Size

The size of the panel

setSize
(size: Size) => void

Function to set the size of the panel

minimize
VoidFunction

Function to minimize the panel

maximize
VoidFunction

Function to maximize the panel

restore
VoidFunction

Function to restore the panel before it was minimized or maximized

resizable
boolean

Whether the panel is resizable

draggable
boolean

Whether the panel is draggable

getResizeTriggerState
(props: ResizeTriggerProps) => ResizeTriggerState

Returns the state of a specific resize trigger

getTriggerState
() => TriggerState

Returns the state of the trigger

getContentState
() => ContentState

Returns the state of the content

getControlState
() => ControlState

Returns the state of the control

getStageTriggerState
(props: StageTriggerProps) => StageTriggerState

Returns the state of a specific stage trigger