Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Overlays

Popover

A floating panel that opens from a trigger and holds richer content than a menu.

Selector: mui-popover

Import
import { Popover, PopoverTrigger } from '@mushilu-san/ui/overlays';
PreviewCode

Loading example…

Overview

Popover opens a panel next to a muiPopoverTrigger element. open is a two-way model, placement sets the side, and heading names the panel.

The panel closes on Escape and on a click outside, unless closeOnEscape or closeOnOutsideClick are turned off. The trigger carries aria-expanded and aria-haspopup.

When to use

  • A small form, filter or details panel tied to one button.
  • Richer content than a menu list can hold.

When not to use

  • A list of actions. Use a dropdown menu. Use Dropdown menu instead.
  • A short hint on hover. Use a tooltip. Use Tooltip instead.

Guidelines

Do

  • Give the panel a heading that says what it is for.
  • Put focus inside the panel when it has form fields.

Don't

  • Do not open a popover on hover. Use a hover card for that.

Accessibility

Roles and attributes

ElementRoleNotes
triggerbutton (native)aria-expanded and aria-haspopup are set automatically.
paneldialogSet with aria-modal="true".

Keyboard

KeysAction
EnterSpaceOpens the panel from the trigger.
EscapeCloses the panel and returns focus to the trigger.
TabShiftTabMoves focus through the panel while it is open.
  • Name the panel with heading, since it is announced when it opens.

API

Popover

Selector: mui-popover

NameTypeDefaultDescription
placement'start' | 'end' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left' | 'right' | 'top' | 'bottom' | 'left-start' | 'left-end' | 'right-start' | 'right-end''bottom' Preferred placement of the panel relative to the trigger.
headingstring | undefined— Optional accessible heading inside the panel.
closeOnOutsideClickbooleantrue Closes the panel on a click outside it. Default `true`. Accepts attribute presence, e.g. <… closeOnOutsideClick>.
closeOnEscapebooleantrue Closes the panel on Escape. Default `true`. Accepts attribute presence, e.g. <… closeOnEscape>.
NameTypeDefaultDescription
openbooleanfalse Two-way open state.
NameTypeDescription
openedvoid Emits when the panel opens.
closedvoid Emits when the panel closes, however it was closed.

CSS parts

  • ::part(heading)
  • ::part(panel)
  • ::part(root)

PopoverTrigger

Selector: [muiPopoverTrigger]

CSS parts

  • ::part(trigger)

Tokens

  • --mui-color-surface-raised
  • --mui-color-border
  • --mui-shadow-4
  • --mui-radius-md
  • --mui-color-focus-ring