Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIComponentsReact

Floating Panel

A window inside the page that stays open while the rest of the page is used: moved by its title bar, resized from a corner, and maximized, minimized or closed from the buttons in the bar.

Built on the headless Floating Panel.See its API in Docs

Rendered by React 19.3.1

floating-panel.tsx

Installation

npx shadcn@4.23.0 add https://hamur.dev/r/react/floating-panel.json

It also adds utils, button. The app needs its setup first: Installation.

Usage

Put a FloatingPanelTrigger and a FloatingPanelPortal inside FloatingPanel, and a FloatingPanelPopup inside the Portal. In the Popup, a FloatingPanelDragHandle holds the FloatingPanelTitle, FloatingPanelMinimize, FloatingPanelMaximize and FloatingPanelClose; a FloatingPanelBody holds the content and a FloatingPanelDescription; a FloatingPanelResizeHandle with position="bottom-right" resizes from the corner. The other seven positions (top, right, bottom, left and the corners) are edges or corners of their own. Opened, the Popup takes focus; the arrow keys move it, Shift with them by 10 pixels, and Alt with them resizes it. defaultPosition, defaultSize, defaultStage, minSize, maxSize, boundary, draggable, resizable, labels and the change and committed callbacks come from the headless Floating Panel.

import {
  FloatingPanel,
  FloatingPanelBody,
  FloatingPanelClose,
  FloatingPanelDescription,
  FloatingPanelDragHandle,
  FloatingPanelMaximize,
  FloatingPanelMinimize,
  FloatingPanelPopup,
  FloatingPanelPortal,
  FloatingPanelResizeHandle,
  FloatingPanelTitle,
  FloatingPanelTrigger,
} from '@/components/ui/floating-panel'

Examples

Default

A tool panel opened from a button, with a title bar, minimize, maximize and close, and a corner grip.

Its preview and code are at the top of the page.

The Popup is the popover surface, 352 CSS pixels wide until a size is given, and never wider or taller than its boundary. It stacks above the page on --panel-index, so the panel used last is in front, with a larger shadow under data-topmost. Minimize, Maximize and Close are the Button's ghost icon-xs, 24 by 24 CSS pixels (WCAG 2.5.8), with a focus ring (WCAG 2.4.7); their icons are hidden from assistive technology. The two toggles are named "Minimize" and "Maximize" through labels and say their state through aria-pressed, drawn as a muted background; Maximize shows a square, and two squares while maximized. Close is named by a visually hidden "Close". The Body scrolls and is hidden while minimized. The resize handles are 8 pixels wide on an edge and 16 on a corner, each with its resize cursor, and are hidden while maximized or minimized, where they cannot resize. Dragging is not the only way to move the panel (WCAG 2.5.7): the arrow keys move it, and buttons of the app can set position. This item takes Base UI's component ID as its slug and one name per Base UI part.

API reference

The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Floating Panel's API reference.