Skip to content
Slotted

Floating panel

A tool that stays over the page while the page stays usable, moved by its handle and kept whole inside the viewport.

Installation

The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.

bash
pnpm add @slotted/react @slotted/theme @slotted/themes
tsx
import { FloatingPanel, FloatingPanelBody, FloatingPanelClose,  FloatingPanelHandle, FloatingPanelTitle } from '@slotted/react';

A tool beside the work

A floating panel is a named region, not a dialog. It draws no scrim, traps no focus and makes nothing inert, so the page under it stays usable and the shortcuts an application holds back while a dialog is open keep working. A press outside the panel does nothing to it. Escape inside the panel and the close control ask onOpenChange(false) in React and emit openChange with false in Angular, and focus returns to the element that held it before the panel opened. Open the pick list, then press Pick one case while the panel stays open: the count in the panel goes up.

Corners

defaultPlace sets the corner the panel stands in until its first move: top-start, top-end, bottom-start or bottom-end. The corners follow the reading direction, so start is the right edge in a right-to-left language. The panel stands --slotted-floating-panel-inset from the edges, and bottom-end is the default. The panel itself is always position: fixed, so Show all docks opens four panels in the corners of the viewport, not of the preview.

Moving the panel

A press on the handle drags the panel, with the pointer captured and no scroll of the page; the panel carries data-dragging while it moves. The grip at the start of the handle is a button named Move. An arrow key on the grip moves the panel one step, and Shift moves it a larger one. A move never takes the panel out of the viewport: the stylesheet clamps its place by the viewport and by the panel’s own size, so the panel stays whole when the window shrinks too. step sets the pixels of an arrow key, 8 by default, and largeStep sets the pixels of an arrow key with Shift, 32 by default. The panel below moves 16 and 64 pixels.

Storing the place

A move reports its end once, by pointer or by key: onPlaceChange in React, placeChange in Angular. The place is the panel’s top-left corner in viewport pixels. Pass it back as place to own the panel’s position, for example to restore it in the next session. A place outside the viewport is drawn inside it. Open the panel and drag it, or pin it to the top left.

A name without a title

The region is named by FloatingPanelTitle. A panel without a title takes its name from aria-label in React and label in Angular, and the title part can be left out. Use it for a tool whose body states its purpose, such as a note.

Messages

The grip and the close control carry names from the language in force: Move and Close. messages overlays one or both for a single panel with move and close.

Accessibility

  • The root is a region named by FloatingPanelTitle or an aria-label, never a dialog: nothing on the page is inert, no scrim takes a press, and focus is not trapped, so the panel is a tool beside the work rather than a step of it.
  • The grip is a button named Move in the language in force; an arrow key moves the panel one step and Shift a larger one, so the panel can be put out of the way without a pointer.
  • Escape inside the panel and the close control ask onOpenChange(false), and focus returns to the element that held it before the panel opened.
  • The place is clamped by the viewport and the panel’s own size in the stylesheet, so a narrowed window or a stored place never leaves part of the tool out of reach.

API

FloatingPanel

Props

openboolean
Whether the panel is drawn
onOpenChange(open: boolean) => void
Asked with false on Escape inside the panel and on its close control
defaultPlace'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'Default bottom-end
The corner the panel stands in until its first move, in the reading direction, --slotted-floating-panel-inset from the edges
place{ x: number; y: number }
A controlled place, the top-left corner in viewport pixels, drawn inside the viewport
stepnumberDefault 8
Pixels an arrow key on the grip moves the panel
largeStepnumberDefault 32
Pixels an arrow key with Shift moves it
onPlaceChange(place) => void
Fired once at the end of a move, by pointer or by key, for the application to store
messagesPartialMessages<FloatingPanelMessages>
Words laid over the catalog of the language in force: close, move
native propssection, div, h2, button attributes
On every partReach the element each part renders

Parts

PartElementRequiredPurpose
rootsectionYesrole="region", named by the title or an aria-label: a tool over the page that holds nobody, with no scrim and nothing made inert. Its place is clamped by the viewport and its own size.
handledivYesThe bar the panel is moved by: a press that moves drags it, with the pointer captured and no scroll of the page.
gripbuttonYesThe handle’s focusable start, named Move in the language in force: an arrow key moves the panel one step, a larger one with Shift.
titleh2NoThe panel’s name, one line, which names the region when no aria-label does.
closebuttonNoCloses the panel; focus returns to the element that held it before it opened.
bodydivYesWhat the tool holds. It scrolls when the panel is held shorter than it.

Theming

Each token is a CSS custom property: set it in a theme, or on any element to retune every floating panel inside it.

Floating panel tokens

TokenDefault
--slotted-floating-panel-backdrop-filternone
--slotted-floating-panel-border-colorvar(--slotted-border-strong, CanvasText)
--slotted-floating-panel-insetvar(--slotted-space-6, 16px)
--slotted-floating-panel-radiusvar(--slotted-radius-lg, 8px)
--slotted-floating-panel-rule-colorvar(--slotted-border-subtle, ButtonBorder)
--slotted-floating-panel-shadowvar(--slotted-shadow-lg, none)
--slotted-floating-panel-surfacevar(--slotted-surface-raised, Canvas)

Theme tokens it reads

TokenDefault
--slotted-border-strongSet per scheme by the theme
--slotted-border-subtleSet per scheme by the theme
--slotted-border-width-thin1px
--slotted-control-inner-size-mdcomfortable 24px · compact 20px · dense 18px
--slotted-focus-ring-colorSet per scheme by the theme
--slotted-focus-ring-offsetvar(--slotted-border-width-thick)
--slotted-focus-ring-widthvar(--slotted-border-width-thick)
--slotted-font-family-headingvar(--slotted-font-family-sans)
--slotted-font-family-sans'Geist Variable', ui-sans-serif, system-ui, sans-serif
--slotted-font-size-sm0.8125rem
--slotted-font-weight-semibold600
--slotted-radius-lg8px
--slotted-radius-sm4px
--slotted-shadow-lgSet per scheme by the theme
--slotted-space-20.25rem
--slotted-space-30.375rem
--slotted-space-50.75rem
--slotted-space-61rem
--slotted-surface-raisedSet per scheme by the theme
--slotted-textSet per scheme by the theme
--slotted-text-mutedSet per scheme by the theme
--slotted-tone-secondary-subtle-hoverSet per scheme by the theme
--slotted-z-index-popover1100