Shopware Design

Floating UI

Source

Usage

Floating UI is a low-level primitive for building custom popover-style surfaces such as rich pickers, menus, inspectors, or inline tools, with automatic positioning relative to a trigger element. Use it when higher-level components such as Action Menu do not fit the custom floating interaction you need.

import { MtFloatingUi } from "@shopware-ag/meteor-component-library";

Examples

Multiple anchors

Use detached mode together with anchorElement to share one floating surface across multiple triggers. The floating panel repositions itself to each anchor as the user hovers, and a short close delay keeps it reachable when the cursor travels from trigger to panel.

API reference

Props

PropTypeDefault
is-opened *boolean
floating-ui-optionsPartial<{ placement?: Placement | undefined; strategy?: Strategy | undefined; middleware?: (false | { name: string; options?: any; fn: (state: { placement: Placement; middlewareData: MiddlewareData; x: number; y: number; initialPlacement: Placement; strategy: Strategy; rects: ElementRects; platform: Platform; elements: Elements; }) => Promisable<MiddlewareReturn>; } | null | undefined)[] | undefined; platform?: Platform | undefined; }> | undefined
show-arrowboolean
offsetnumber
auto-update-optionsPartial<AutoUpdateOptions>
match-reference-width
If true, the floating UI content will match the width of the reference element.
boolean
anchor-element
An external DOM element to anchor the floating content to, instead of the built-in trigger slot wrapper
HTMLElement | null
detached
When true, the trigger slot is not rendered and the root wrapper is not displayed Use with `anchorElement`.
boolean

Events

EventPayload
close[]

Slots

SlotBindings
trigger{}
default{ referenceElementWidth: number; referenceElementHeight: number; }

Best practices

Do
  • Manage the open state outside the component and update it through isOpened and the close event.
  • Provide a clear trigger element so users understand what opens the floating surface.
  • Style the slotted content as a complete surface, including background, border, spacing, and shadow.
  • Use matchReferenceWidth when the floating surface should align to the trigger width.
Don't
  • Do not use Floating UI when a higher-level component such as Action Menu already fits the use case.
  • Do not rely on it to provide a finished surface design. It only handles positioning and behavior.
  • Do not forget to handle keyboard and focus behavior for custom interactive content.

Behavior

  • Floating UI teleports its content to body, so the floating surface can escape clipping and stacking issues in the local layout.
  • It uses Floating UI middleware to offset, flip, and measure the floating surface automatically.
  • showArrow adds an arrow element, but the slotted content still needs to provide the actual surface styling.
  • The default slot receives referenceElementWidth and referenceElementHeight, which help when the floating content needs to size itself relative to the trigger.
  • matchReferenceWidth sets the floating container width to the trigger width automatically.

Accessibility

  • Make sure the trigger clearly communicates what it opens.
  • If the floating content contains interactive controls, manage focus and keyboard behavior intentionally.
  • Provide visible structure and labels inside the floating surface so the custom content stays understandable once opened.
  • Popover: when the standard popover styling and interaction model already fit.
  • Action Menu: when you need a standard menu of actions or options.