1. framework components
  2. floating panel

Floating Panel

A draggable, resizable floating panel with minimize/maximize controls.

Warning

This feature is currently marked as beta and not intended for production use. It may receive breaking changes before its stable release.

Size Constraints

Use the minSize and maxSize props to set size constraints on the Floating Panel.

Controlled

Control the open state and size of the Floating Panel with your own state.

Anchor Position

Position the panel relative to another element using the defaultPosition prop.

Resize Triggers

Add resize triggers on all sides and corners of the Floating Panel using the axis prop.

Disable Dragging

Disable dragging by setting the draggable prop to false. The panel will remain in a fixed position but can still be resized.

Disable Resizing

Disable resizing by setting the resizable prop to false. The panel will have a fixed size but can still be dragged.

Direction

Set the text direction (ltr or rtl) using the dir prop.

Anatomy

Here’s an overview of how the Floating Panel component is structured in code:

tsx
import { FloatingPanel, Portal } from '@skeletonlabs/skeleton-react';

export default function Anatomy() {
	return (
		<FloatingPanel>
			<FloatingPanel.Trigger />
			<Portal>
				<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>
			</Portal>
		</FloatingPanel>
	);
}

API Reference

Root

PropDefaultType
childrenReactNode

idsPartial<{ trigger: string; positioner: string; content: string; title: string; header: string; }> | undefined

The ids of the elements in the floating panel. Useful for composition.

translationsIntlTranslations | undefined

The translations for the floating panel.

strategy"fixed""absolute" | "fixed" | undefined

The strategy to use for positioning

allowOverflowtrueboolean | undefined

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

openboolean | undefined

The controlled open state of the panel

defaultOpenfalseboolean | undefined

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

draggabletrueboolean | undefined

Whether the panel is draggable

resizabletrueboolean | undefined

Whether the panel is resizable

sizeSize | undefined

The size of the panel

defaultSizeSize | undefined

The default size of the panel

minSizeSize | undefined

The minimum size of the panel

maxSizeSize | undefined

The maximum size of the panel

positionPoint | undefined

The controlled position of the panel

defaultPositionPoint | undefined

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

getAnchorPosition((details: AnchorPositionDetails) => Point) | undefined

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

lockAspectRatioboolean | undefined

Whether the panel is locked to its aspect ratio

closeOnEscapeboolean | undefined

Whether the panel should close when the escape key is pressed

getBoundaryEl(() => HTMLElement | null) | undefined

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

disabledboolean | undefined

Whether the panel is disabled

onPositionChange((details: PositionChangeDetails) => void) | undefined

Function called when the position of the panel changes via dragging

onPositionChangeEnd((details: PositionChangeDetails) => void) | undefined

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

onOpenChange((details: OpenChangeDetails) => void) | undefined

Function called when the panel is opened or closed

onSizeChange((details: SizeChangeDetails) => void) | undefined

Function called when the size of the panel changes via resizing

onSizeChangeEnd((details: SizeChangeDetails) => void) | undefined

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

persistRectboolean | undefined

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

gridSize1number | undefined

The snap grid for the panel

onStageChange((details: StageChangeDetails) => void) | undefined

Function called when the stage of the panel changes

dir"ltr""ltr" | "rtl" | undefined

The document's text/writing direction.

getRootNode(() => Node | ShadowRoot | Document) | undefined

A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.

Provider

PropDefaultType
valueFloatingPanelApi<PropTypes>

childrenReactNode

Context

PropDefaultType
children(floatingPanel: FloatingPanelApi<PropTypes>) => ReactNode

Trigger

PropDefaultType
element((attributes: HTMLAttributes<"button">) => Element) | undefined

Render the element yourself

Positioner

PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Content

txt
card overflow-hidden shadow-lg border border-surface-300-700
PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

DragTrigger

PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Header

txt
px-4 py-2 grid grid-cols-[1fr_auto] gap-2 items-center bg-surface-200-800 overflow-y-hidden
PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Title

txt
flex justify-start items-center gap-2 whitespace-nowrap
PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Control

txt
flex gap-1
PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

StageTrigger

txt
btn-icon hover:preset-tonal
PropDefaultType
stageStage

The stage of the panel

element((attributes: HTMLAttributes<"button">) => Element) | undefined

Render the element yourself

CloseTrigger

txt
btn-icon hover:preset-tonal
PropDefaultType
element((attributes: HTMLAttributes<"button">) => Element) | undefined

Render the element yourself

Body

txt
h-full bg-surface-100-900 p-4 overflow-y-auto
PropDefaultType
element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

ResizeTrigger

txt
data-[axis*=n]:h-2 data-[axis*=s]:h-2 data-[axis*=e]:w-2 data-[axis*=w]:w-2 data-[axis=n]:top-0
PropDefaultType
axisResizeTriggerAxis

The axis of the resize handle

element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

View page on GitHub