shadcn.io is an independent project built on shadcn/ui
Components
Free
Floating Panel for Solid
A window people can drag, resize, minimize and maximize while the page under it stays usable. A Solid floating panel to use with Ark UI.
On this page9 sections
UI library: Ark UI
A floating panel is a small window over the page that people drag by its header, resize from any edge or corner, and minimize or maximize from its title bar. The page under it keeps working, which suits an inspector, a font or color palette, or notes kept open beside the work.
When a task should stop everything else until it's done, use a Dialog instead.
Installation
Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
FloatingPanelHeader is the drag handle, and FloatingPanelContent adds the resize handles on every edge and corner.
<FloatingPaneldefaultSize={{ width: 360, height: 240 }}>
<FloatingPanelTriggerasChild={(props) => (
<Button {...props()} variant="outline">Open notes</Button>
)}
/>
<FloatingPanelContent>
<FloatingPanelHeader>
<FloatingPanelTitle>Notes</FloatingPanelTitle>
<FloatingPanelControl>
<FloatingPanelMinimize />
<FloatingPanelMaximize />
<FloatingPanelRestore />
<FloatingPanelCloseTriggerasChild={(props) => (
<Button {...props()} aria-label="Close"size="icon-xs"variant="ghost">
<XIconaria-hidden />
</Button>
)}
/>
</FloatingPanelControl>
</FloatingPanelHeader>
<FloatingPanelBody>
<p>Drag the header to move this window, or pull an edge to resize it.</p>
</FloatingPanelBody>
</FloatingPanelContent>
</FloatingPanel>
Accessibility
The panel is a role="dialog" named by FloatingPanelTitle. Opening it moves focus to the panel itself, and closing it hands focus back to the trigger. It isn't modal, so focus isn't trapped and the rest of the page keeps working. Dragging and resizing need a pointer, but the arrow keys move the panel while it has focus. The minimize, maximize and restore buttons come with labels, and the close trigger reads Close Window unless you give it a label of your own.
KeyAction
Tab
Moves focus to the next focusable element. Focus isn't trapped inside the panel.
Shift+Tab
Moves focus to the previous focusable element.
Enter
On the trigger, opens or closes the panel. On a header button, minimizes, maximizes, restores or closes it.
Space
On the trigger, opens or closes the panel. On a header button, minimizes, maximizes, restores or closes it.
Arrow Left
When the panel itself has focus, moves it left by one pixel, or ten with Shift.
Arrow Right
When the panel itself has focus, moves it right by one pixel, or ten with Shift.
Arrow Up
When the panel itself has focus, moves it up by one pixel, or ten with Shift.
Arrow Down
When the panel itself has focus, moves it down by one pixel, or ten with Shift.
EscEscape
Closes the panel when closeOnEscape is set on FloatingPanel. During a drag or a resize, puts the panel back as it was when it started.
Demos
Controlled position
The panel's position lives in state, filled by onPositionChange when the panel opens and again as you drag the header. The body prints x and y, and four arrow buttons inside the panel move it 20 pixels at a time. Control the position when something else on the page moves the panel, or when you save where people left it.
Controlled size
size lives in state, starting at 360 by 200, and dragging an edge writes the new size back through onSizeChange. Shrink and Grow at the top of the panel change it by 50 by 40, and the readout follows. minSize stops a drag at 240 by 160 but doesn't clamp a size you pass in, so the Shrink handler clamps to the same floor.
Custom spacing
The font settings panel from the top of the page, with its padding changed in one place. FloatingPanelContent sets --space, which the header, body and footer all read, and this one uses --spacing(3) on a phone and --spacing(6) from the sm breakpoint up. Change that variable instead of padding each part, so the three keep the same inset.
Inside a container
A layers panel for a page editor that stays inside the dashed canvas around it. allowOverflow is false and getBoundaryEl returns the canvas element, so the panel opens centered in it, a drag stops at its edges, and Maximize fills the canvas rather than the window. Reach for it when a tool belongs to one region of the page.
FAQ
When should I use a Floating Panel instead of a Dialog or a Popover?
Use a Floating Panel for a tool people keep open while they work on the page: an inspector, a layer list, a chat or a set of notes. It stays until they close it, a click outside doesn't dismiss it, and they can move it out of the way.
A Dialog blocks the page until its task is done or canceled. A Popover is pinned to the button that opened it and closes on a click outside, which suits a quick edit. On a phone, a Sheet from the edge of the screen fits better than a window people have to drag.
How do I control a Floating Panel's position in Solid?
Keep the position in state, pass it as position on FloatingPanel and update it in onPositionChange, which receives an object whose position holds x and y. The callback fires on every step of a drag, and on opening while there's no position yet. onPositionChangeEnd fires once when a drag ends, which is the moment to save it.
Without a position, the panel opens centered in the window. defaultPosition sets where it first appears, and getAnchorPosition computes the spot from the trigger's rect, for a panel that opens next to its button.
How do I control the size of a Floating Panel?
Keep the size in state, pass it as size on FloatingPanel and update it in onSizeChange, which receives an object whose size holds width and height, as the Controlled size demo does.
When you only care about the first size, set defaultSize. Without it the panel opens at 320 by 240. minSize and maxSize bound what a drag can reach, and lockAspectRatio keeps the proportions while resizing.
How do I open a Floating Panel from state in Solid?
Pass a boolean as open on FloatingPanel and update it in onOpenChange, which receives an object with the next state in open.
A panel that keeps its own open state goes back to its starting size and position when it closes. Add persistRect to reopen it where people left it.
A closed panel's content also leaves the DOM, so fields inside start over each time it opens. Set lazyMount and unmountOnExit to false to keep them.
How do I minimize or maximize a Floating Panel?
Put FloatingPanelMinimize, FloatingPanelMaximize and FloatingPanelRestore in FloatingPanelControl inside the header. The first two hide while the panel is minimized or maximized, and Restore shows only then. A double-click on the header also maximizes the panel, or restores it.
Each change is reported to onStageChange on FloatingPanel, and the content carries data-minimized, data-maximized and data-staged for styling. Setting resizable to false on FloatingPanel turns off resizing and staging together: the edge handles and the three buttons leave the panel, and a double-click on the header does nothing. To drop only the edge handles, set it to false on FloatingPanelContent instead.
Why doesn't Escape close my Floating Panel?
Ark UI leaves it open unless you set closeOnEscape on FloatingPanel. A panel is often a tool people keep beside their work, so closing it by accident would lose their place.
With the option on, Escape closes the panel when focus is inside it and it's the topmost panel on the page. A click outside never closes it, so give it a close button, as the demos do.
How do I keep a Floating Panel inside the window or a container?
Set allowOverflow to false on FloatingPanel. As it ships, a drag can carry the panel past the left, right and bottom edges of the window, though never above the top.
To bound it by an element instead of the window, also pass getBoundaryEl a function that returns that element, such as the canvas of an editor. With allowOverflow off, the panel then opens centered in that element and stays inside its rect while people drag and resize it, as the Inside a container demo shows.
How do I change the padding inside a Floating Panel?
Set the --space variable on FloatingPanelContent, as the Custom spacing demo does. The header, body and footer all read it for their padding, and it starts at --spacing(4).
Changing that one value keeps the three parts in line, where padding each part yourself leaves them uneven. The window's own place and size come from --x, --y, --width and --height on the positioner, which the panel sets as it moves.
API Reference
FloatingPanel
data-slot="floating-panel"
PropType
open?boolean
The controlled open state of the panel.
defaultOpen?boolean
The initial open state of the panel when rendered.
Use when you don't need to control the open state of the panel.
Default
false
onOpenChange?(details: OpenChangeDetails) → void
Function called when the panel is opened or closed.
Type
(details: OpenChangeDetails) → void
Parameters
details – { open: boolean }
Returns
void
position?object
The controlled position of the panel.
Type
{ x: number; y: number }
defaultPosition?object
The initial position of the panel when rendered.
Use when you don't need to control the position of the panel.
The boundary of the panel. Useful for recalculating the boundary rect when
the it is resized.
Type
() → HTMLElement | null
Returns
HTMLElement | null
gridSize?number
The snap grid for the panel.
Default
1
hideMode?"display-none" | "activity"
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+.
Type
"display-none" | "activity"
Default
"display-none"
id?string
The unique identifier of the machine.
ids?object
The ids of the elements in the floating panel. Useful for composition.