Vibary.ai
← Vibe Coding

Popover Anchor Flip

A popover opens below its trigger, or flips above when space runs out — the arrow follows.

navigationelegantsubtleinteraction · finite · intermediate · ~0.2s
Interactive · click to play
Variant

The animated component in this preview is rendered from the canonical file shown here. The surrounding demo shell only provides context and is not part of the copied code.

403 lines · react + motion only
import { useEffect, useId, useRef, useState } from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";

/**
 * Vibary · Popover Anchor Flip
 *
 * A row menu opens below the control that summoned it — unless the frame
 * runs out of room, in which case it flips above and the arrow moves with

About this pattern

Row actions, overflow menus and any panel that belongs to one control. The motion is two decisions made together: measure the room left below the trigger and cross to the other side only when it is genuinely roomier, then grow the panel out of the corner nearest that trigger so the tie back to what was clicked is never broken. The arrow is drawn inside the panel, so it flips with it rather than being repositioned separately. Springs stay near critical damping because a menu is read the instant it lands, and the scale starts high enough that the labels never look resized on the way in.

Row overflow menuAccount menuFilter panel on a toolbarInline actions in a long feed

Where it shows up

Screens we drew to show where this motion usually sits. Illustrations, not captures of any product.

  • Ridgeline
    Docs
    Recent
    Shared
    Templates
    Trash
    DocsNew
    Q3 planning notesEdited 14 minutes agoScope
    Sidebar navigation

    A menu grows from the corner nearest its button and changes side close to a screen edge.

Related patterns