This is a floating panel that can be dragged, resized, minimized, and maximized. Try dragging from the header or resizing from the bottom-right corner.
This is a floating panel that can be dragged, resized, minimized, and maximized. Try dragging from the header or resizing from the bottom-right corner.
Size Constraints
Use the minSize and maxSize props to set size constraints on the Floating Panel.
This panel has size constraints applied: minimum 300x200 pixels and maximum 900x600 pixels.
Try resizing from the bottom-right corner - the panel will respect these boundaries.
This panel has size constraints applied: minimum 300x200 pixels and maximum 900x600 pixels.
Try resizing from the bottom-right corner - the panel will respect these boundaries.
Controlled
Control the open state and size of the Floating Panel with your own state.
This panel's open state and size are controlled via the inputs above.
Try changing the values or resizing/closing the panel to see the inputs update.
This panel's open state and size are controlled via the inputs above.
Try changing the values or resizing/closing the panel to see the inputs update.
Anchor Position
Position the panel relative to another element using the defaultPosition prop.
This panel is centered in the viewport using getAnchorPosition.
The position is calculated based on the boundary rectangle.
This panel is centered in the viewport using getAnchorPosition.
The position is calculated based on the boundary rectangle.
Resize Triggers
Add resize triggers on all sides and corners of the Floating Panel using the axis prop.
This is a floating panel that can be dragged, resized, minimized, and maximized. Try dragging from the header or resizing from the bottom-right corner.
This is a floating panel that can be dragged, resized, minimized, and maximized. Try dragging from the header or resizing from the bottom-right corner.
Disable Dragging
Disable dragging by setting the draggable prop to false. The panel will remain in a fixed position but can still be resized.
This panel cannot be dragged - the position is fixed.
However, it can still be resized from the bottom-right corner.
This panel cannot be dragged - the position is fixed.
However, it can still be resized from the bottom-right corner.
Disable Resizing
Disable resizing by setting the resizable prop to false. The panel will have a fixed size but can still be dragged.
This panel cannot be resized.
Try dragging the edges - they won't respond.
This panel cannot be resized.
Try dragging the edges - they won't respond.
Direction
Set the text direction (ltr or rtl) using the dir prop.
This is a floating panel with right-to-left (RTL) direction.
You can drag it from the header or resize it from the bottom-right corner.
This is a floating panel with right-to-left (RTL) direction.
You can drag it from the header or resize it from the bottom-right corner.
Anatomy
Here’s an overview of how the Floating Panel component is structured in code:
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.Body>
</FloatingPanel.Content>
</FloatingPanel.Positioner>
</Portal>
</FloatingPanel>
);
}<script lang="ts">
import { FloatingPanel, Portal } from '@skeletonlabs/skeleton-svelte';
</script>
<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.Body>
</FloatingPanel.Content>
</FloatingPanel.Positioner>
</Portal>
</FloatingPanel>API Reference
Root
| Prop | Default | Type |
|---|---|---|
children | — | ReactNode |
ids | — | Partial<{ trigger: string; positioner: string; content: string; title: string; header: string; }> | undefined The ids of the elements in the floating panel. Useful for composition. |
translations | — | IntlTranslations | undefined The translations for the floating panel. |
strategy | "fixed" | "absolute" | "fixed" | undefined The strategy to use for positioning |
allowOverflow | true | boolean | undefined Whether the panel should be strictly contained within the boundary when dragging |
open | — | boolean | undefined The controlled open state of the panel |
defaultOpen | false | boolean | undefined The initial open state of the panel when rendered. Use when you don't need to control the open state of the panel. |
draggable | true | boolean | undefined Whether the panel is draggable |
resizable | true | boolean | undefined Whether the panel is resizable |
size | — | Size | undefined The size of the panel |
defaultSize | — | Size | undefined The default size of the panel |
minSize | — | Size | undefined The minimum size of the panel |
maxSize | — | Size | undefined The maximum size of the panel |
position | — | Point | undefined The controlled position of the panel |
defaultPosition | — | Point | 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. |
lockAspectRatio | — | boolean | undefined Whether the panel is locked to its aspect ratio |
closeOnEscape | — | boolean | 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. |
disabled | — | boolean | 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 |
persistRect | — | boolean | undefined Whether the panel size and position should be preserved when it is closed |
gridSize | 1 | number | 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
| Prop | Default | Type |
|---|---|---|
value | — | FloatingPanelApi<PropTypes> |
children | — | ReactNode |
Context
| Prop | Default | Type |
|---|---|---|
children | — | (floatingPanel: FloatingPanelApi<PropTypes>) => ReactNode |
Trigger
| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"button">) => Element) | undefined Render the element yourself |
Positioner
| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
Content
card overflow-hidden shadow-lg border border-surface-300-700| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
Header
px-4 py-2 grid grid-cols-[1fr_auto] gap-2 items-center bg-surface-200-800 overflow-y-hidden| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
Body
h-full bg-surface-100-900 p-4 overflow-y-auto| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
Title
flex justify-start items-center gap-2 whitespace-nowrap| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
ResizeTrigger
data-[axis*=n]:h-2 data-[axis*=s]:h-2 data-[axis*=e]:w-2 data-[axis*=w]:w-2| Prop | Default | Type |
|---|---|---|
axis | — | ResizeTriggerAxis The axis of the resize handle |
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
DragTrigger
| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
StageTrigger
btn-icon hover:preset-tonal| Prop | Default | Type |
|---|---|---|
stage | — | Stage The stage of the panel |
element | — | ((attributes: HTMLAttributes<"button">) => Element) | undefined Render the element yourself |
CloseTrigger
btn-icon hover:preset-tonal| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"button">) => Element) | undefined Render the element yourself |
Control
flex gap-1| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
Root
| Prop | Default | Type |
|---|---|---|
ids | — | Partial<{ trigger: string; positioner: string; content: string; title: string; header: string; }> | undefined The ids of the elements in the floating panel. Useful for composition. |
translations | — | IntlTranslations | undefined The translations for the floating panel. |
strategy | "fixed" | "absolute" | "fixed" | undefined The strategy to use for positioning |
allowOverflow | true | boolean | undefined Whether the panel should be strictly contained within the boundary when dragging |
open | — | boolean | undefined The controlled open state of the panel |
defaultOpen | false | boolean | undefined The initial open state of the panel when rendered. Use when you don't need to control the open state of the panel. |
draggable | true | boolean | undefined Whether the panel is draggable |
resizable | true | boolean | undefined Whether the panel is resizable |
size | — | Size | undefined The size of the panel |
defaultSize | — | Size | undefined The default size of the panel |
minSize | — | Size | undefined The minimum size of the panel |
maxSize | — | Size | undefined The maximum size of the panel |
position | — | Point | undefined The controlled position of the panel |
defaultPosition | — | Point | 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. |
lockAspectRatio | — | boolean | undefined Whether the panel is locked to its aspect ratio |
closeOnEscape | — | boolean | 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. |
disabled | — | boolean | 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 |
persistRect | — | boolean | undefined Whether the panel size and position should be preserved when it is closed |
gridSize | 1 | number | 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. |
children | — | Snippet<[]> | undefined The default slot content to be rendered within the component. |
Provider
| Prop | Default | Type |
|---|---|---|
value | — | () => FloatingPanelApi<PropTypes> |
children | — | Snippet<[]> | undefined The default slot content to be rendered within the component. |
Context
| Prop | Default | Type |
|---|---|---|
children | — | Snippet<[() => FloatingPanelApi<PropTypes>]> |
Trigger
| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"button">]> | undefined Render the element yourself |
Positioner
| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
Content
card overflow-hidden shadow-lg border border-surface-300-700| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
Header
px-4 py-2 grid grid-cols-[1fr_auto] gap-2 items-center bg-surface-200-800 overflow-y-hidden| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
Body
h-full bg-surface-100-900 p-4 overflow-y-auto| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
Title
flex justify-start items-center gap-2 whitespace-nowrap| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
ResizeTrigger
data-[axis*=n]:h-2 data-[axis*=s]:h-2 data-[axis*=e]:w-2 data-[axis*=w]:w-2| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
axis | — | ResizeTriggerAxis The axis of the resize handle |
DragTrigger
| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
StageTrigger
btn-icon hover:preset-tonal| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"button">]> | undefined Render the element yourself |
stage | — | Stage The stage of the panel |
CloseTrigger
btn-icon hover:preset-tonal| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"button">]> | undefined Render the element yourself |
Control
flex gap-1| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |