Skip to content
hightouchUI

Design system

4a0e71b

Morphing popover

Morphing popover is a popover whose trigger grows into it: the trigger's surface becomes the popover, and the trigger's content, its face, travels to its place inside.

Use Popover when the trigger is a regular button and the popover can simply appear beside it.

Example

Click the pill. Its face lands on the open surface's first row, which closes the popover again.

Usage

Face

Pass the face once, as face on MorphingPopover. MorphingPopoverTrigger shows it, and MorphingPopoverFace marks where it lands in the open surface. The face there takes the trigger's padding, so the two line up as the surface starts to grow.

When the face starts with a round element, set pl={1} on the trigger, so the element sits concentric with the pill's round end.

Closing from inside

The face already closes a click popover. To close it from another action in the surface without controlling isOpen, pass a function as the children. It receives isOpen and onClose, as Popover's does.

Sections

As the surface opens, its sections fade in one after another: each child of MorphingPopoverContent, and anything that shares a row with the face. A section that sets its own opacity keeps it on an element inside, since the fade sets the section's opacity.

Placement

The surface grows from the trigger's corner that placement names. Use top-start for a pill that sits low on its surface, like one above a prompt input. The surface flips when space is tight, and narrows to the room beside its anchor when neither side fits the requested width. Its height stays within the viewport, so long content scrolls inside it.

Marker

Set variant="marker" for a comment marker whose preview grows out of it on hover, with its point at the corner it grows from. Add onClick to MorphingPopoverTrigger to open the full thread: hover this marker to read its preview, then click it or press Enter to open the thread.

Hover

Set trigger="hover" for a preview that grows out of its trigger on hover or focus, as the marker above does. Focus stays on the trigger. The preview stays open while the pointer is over either the trigger or the preview, and Esc dismisses it even when the trigger has no focus. A preview never takes focus, so put controls in a click popover instead.

openDelay sets the initial hover delay. Previews can open immediately when another preview has recently been open. closeDelay gives the pointer time to move between the trigger and the preview. Set isDisabled on MorphingPopoverTrigger when its action is unavailable to disable both activation and the preview.

Guidelines

When to use

  • The trigger sums something up in a small space, such as a count of running jobs or a comment marker, and the surface is that same thing opened up.
  • The surface shows the detail or a short preview of what the trigger sums up, with a few actions at most.
  • The trigger sits in one place and is opened now and then, such as one pill above a prompt input or one marker on a canvas.

When not to use

  • When a button or an icon button opens a panel of its own beside it, use Popover.
  • For a list of actions or choices, use Menu.
  • For a larger view of an image or video on hover, use Media preview.
  • For a short hint in plain text, use Tooltip.
  • For a form or a task with steps, use Dialog or Drawer.
  • When the trigger repeats in every row of a dense list or table, use Popover, so the page doesn't move on every open.
  • Inside another morphing popover, or beside one that is already open in the same place. Open one at a time.

Motion

  • The morph is why the surface must be the trigger itself: it shows one object opening up, and a surface that is something else would read as the trigger turning into it.
  • The component owns the motion: the spring, the sections' fade and reduced motion. Don't add motion of your own to the trigger or the surface.

Content

  • Keep the face to a count and a short label, so the pill stays small.

Accessibility

  • With a click trigger, focus moves to the face when the popover opens. Esc or a click outside closes it and returns focus to the trigger.
  • Give the trigger an aria-label when its face is a count or an icon alone, and give the face one that says it closes the popover.
  • A hover preview describes its trigger with the preview's text. It hides its duplicate face from assistive tech, which already reads the trigger.

Props

Inherits margin props on MorphingPopoverTrigger, horizontal padding props (px, pl, pr) on MorphingPopoverTrigger, which MorphingPopoverFace copies, and padding props on MorphingPopoverContent.

MorphingPopover

NameDefaultDescription
children

—

ReactNode | ((state: { isOpen: boolean; onClose: () => void }) => ReactNode)MorphingPopoverTrigger and MorphingPopoverContent. The face already closes a click popover. Pass a function of { isOpen, onClose } so another action in the surface can close it too, without controlling isOpen.
face

—

ReactNodeWhat the trigger shows, such as a count and a short label. MorphingPopoverTrigger and MorphingPopoverFace both render it, so the face that travels into the open surface always matches the trigger. A node, because a face is often a count beside a label.
placement"bottom-start", or "top-start" for the marker, which grows away from its pointExtract< | PlacementWithLogical, | "top-start" | "top-end" | "bottom-start" | "bottom-end" | >The trigger's corner the surface grows from, and the side it grows toward. It flips to the other side, or the other end, when the viewport has no room.
trigger"click""click" | "hover"click toggles a surface that takes focus and holds controls. hover opens a preview on hover or focus, which leaves focus on the trigger.
variant"pill""pill" | "marker"The trigger's look, which the surface starts from. pill is a white pill with a hairline. marker is a comment marker on a canvas: the light marker material, with a point at its bottom-left corner. The corner the surface grows from ends at the trigger's sharpest radius, so the point stays on that corner, and moves to it when the surface flips.
isOpen

—

booleanControls whether the popover is open. Leave it out for a popover that opens and closes itself.
onOpen

—

() => voidCalled when the popover asks to open: on a click, or on hover or focus with a hover trigger.
onClose

—

() => voidCalled when the popover asks to close: on <kbd>Esc</kbd>, a click outside, the face, the trigger, the pointer leaving a hover popover, or the trigger turning disabled.
openDelay200numberThe initial hover delay, in milliseconds. Previews can open immediately when another preview has recently been open.
closeDelay200numberWith a hover trigger, how long the popover stays open after the pointer leaves it, in milliseconds.

MorphingPopoverTrigger

NameDefaultDescription
aria-label

—

stringNeeded when the face has no text, or its text does not say what the popover holds.
onClick

—

ComponentProps<"button">["onClick"]Called when the trigger is activated. A hover preview closes before this action runs.
isDisabled

—

booleanBlocks the trigger's click and its hover or focus preview, and closes the popover if it is open. It sits on the trigger, not the root as on Tooltip, because it disables the trigger's own button.

MorphingPopoverContent

NameDefaultDescription
children

—

ReactNodeWhat the open surface holds, with one MorphingPopoverFace where the face lands.
aria-label

—

stringNames a click popover, which otherwise takes its trigger's name. A hover preview describes its trigger with its content.
width"xs"LayoutProps["width"]The open surface's width.

MorphingPopoverFace

NameDefaultDescription
aria-label

—

stringNeeded when the face has no text, or its text does not say what the button does. A hover face is hidden from assistive tech, so it ignores this.