Skip to content
Focsd homeFocsd homeFocsd
Forms

Floating panel

A non-modal card that floats above the page and can be dragged anywhere on screen: notes, help, inspectors, chat.

  • Tag: focsd-floating-panel
  • Pattern: Non-modal dialog, draggable, keyboard move (WCAG 2.5.7)
  • Category: Overlays

Example

Notes

Drag me by the header, or use the move button and the arrow keys.

HTML
<focsd-button id="notes-open">Notes</focsd-button>
<focsd-floating-panel label="Notes" trigger="notes-open">
<p>Drag me by the header, or use the move button and the arrow keys.</p>
<focsd-textarea label="Note"></focsd-textarea>
</focsd-floating-panel>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/components/focsd-floating-panel.js';
</script>
<focsd-floating-panel label="Notes" trigger="notes-open">…</focsd-floating-panel>

API

Attributes

AttributePropertyTypeDefault
labellabelstring—
openopenbooleanfalse
triggertriggerstring—

Methods

MethodDescription
show()Open the panel and move focus into it.
close()Close the panel; focus returns to the trigger (or the element focused before opening).
moveTo(x, y)Move the panel to (x, y) CSS pixels from the top left of the viewport, kept on screen.

Events

EventDescription
closeFired after the panel closes. Like <dialog>, it does not bubble.

Slots

SlotDescription
(default)The panel content.

CSS parts

Style the inside of the component with ::part(), for example focsd-floating-panel::part(panel).

PartDescription
panelThe floating panel (role="dialog").
headerThe draggable header.
titleThe title.
move-handleThe move button (arrow keys move the panel).
closeThe close button.
bodyThe content area.

Accessibility

  • A non-modal role="dialog" named by label; the page stays usable while it is open, and the trigger gets aria-expanded.
  • Dragging has a keyboard alternative (WCAG 2.5.7): the move button moves the panel with the arrow keys.
  • The panel always stays fully on screen, including when the window is resized, and remembers where it was moved.
  • Several panels can be open at once; the one you click or focus comes to the front.

Keyboard

KeyAction
Enter / Space (trigger)Open or close
Arrow keys (move button)Move 10px
Shift + arrow keys (move button)Move 50px
EscapeClose and return focus to the trigger