Floating Panel
Used to display content in a non-modal floating window.
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
| Prop | Default | Type |
|---|---|---|
allowOverflow | true | booleanWhether the panel should be strictly contained within the boundary when dragging |
closeOnEscape | booleanWhether the panel should close when the escape key is pressed | |
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. |
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 | |
dir | 'ltr' | 'ltr' | 'rtl'The document's text/writing direction. |
disabled | booleanWhether the panel is disabled | |
draggable | true | booleanWhether the panel is draggable |
finalFocusEl | () => HTMLElement | nullElement to receive focus when the panel is closed. By default, the trigger element is focused. | |
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. | |
gridSize | 1 | numberThe snap grid for the panel |
hideMode | 'display-none' | HideModeHow 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 | stringThe unique identifier of the machine. | |
ids | ElementIdsThe 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 | |
initialFocusEl | () => false | HTMLElement | nullElement 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. | |
lazyMount | false | booleanWhether to enable lazy mounting |
lockAspectRatio | booleanWhether the panel is locked to its aspect ratio | |
maxSize | SizeThe maximum size of the panel | |
minSize | SizeThe minimum size of the panel | |
onEnterComplete | VoidFunctionFunction called when the animation ends in the open state | |
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) | |
resizable | true | booleanWhether the panel is resizable |
restoreFocus | true | booleanWhether to restore focus to the trigger when the panel is closed. |
size | SizeThe size of the panel | |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
strategy | 'fixed' | 'absolute' | 'fixed'The strategy to use for positioning |
translations | IntlTranslationsThe translations for the floating panel. | |
unmountOnExit | false | booleanWhether to unmount on exit. |
Body
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-floating-panel-drag-trigger] | <uid> |
[data-disabled] | Present when disabled |
Header
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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 Variable | Description |
|---|---|
--width | The width of the element |
--height | The height of the element |
--x | The x position for transform |
--y | The y position for transform |
--layer-index | The index of the panel in the panel stack |
ResizeTrigger
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
placement | CompassDirectionThe placement of the resize handle | |
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-floating-panel-resize-trigger] | <uid> |
[data-disabled] | Present when disabled |
[data-placement] | The placement of the resizetrigger |
RootProvider
| Prop | Default | Type |
|---|---|---|
value | UseFloatingPanelReturn | |
hideMode | 'display-none' | HideModeHow 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 | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
lazyMount | false | booleanWhether to enable lazy mounting |
onEnterComplete | VoidFunctionFunction called when the animation ends in the open state | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
unmountOnExit | false | booleanWhether to unmount on exit. |
StageTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
stage | StageThe stage of the panel | |
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-floating-panel-stage-trigger] | <uid> |
[data-stage] | The stage of the stagetrigger |
Title
Defines the <h2> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse 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. |
| Attribute | Description |
|---|---|
[data-floating-panel-trigger] | <uid> |
[data-state] | "open" | "closed" |
[data-dragging] | Present when in the dragging state |
Context
API
| Property | Type |
|---|---|
open | booleanWhether the panel is open |
setOpen | (open: boolean, reason?: OpenChangeReason) => voidFunction to open or close the panel |
dragging | booleanWhether the panel is being dragged |
resizing | booleanWhether the panel is being resized |
position | PointThe position of the panel |
setPosition | (position: Point) => voidFunction to set the position of the panel |
size | SizeThe size of the panel |
setSize | (size: Size) => voidFunction to set the size of the panel |
minimize | VoidFunctionFunction to minimize the panel |
maximize | VoidFunctionFunction to maximize the panel |
restore | VoidFunctionFunction to restore the panel before it was minimized or maximized |
resizable | booleanWhether the panel is resizable |
draggable | booleanWhether the panel is draggable |
getResizeTriggerState | (props: ResizeTriggerProps) => ResizeTriggerStateReturns the state of a specific resize trigger |
getTriggerState | () => TriggerStateReturns the state of the trigger |
getContentState | () => ContentStateReturns the state of the content |
getControlState | () => ControlStateReturns the state of the control |
getStageTriggerState | (props: StageTriggerProps) => StageTriggerStateReturns the state of a specific stage trigger |