Popover
Also called flyout or popup panel
A small floating panel anchored to the button that opened it, often with an arrow, holding a few controls and closing when you click outside.
import { Popover } from '@base-ui/react/popover';
import { Switch } from '@base-ui/react/switch';
export function SharePopover() {
return (
<Popover.Root>
<Popover.Trigger className='rounded-lg border px-4 py-2 text-sm font-medium hover:bg-muted data-popup-open:bg-muted'>
Share
</Popover.Trigger>
<Popover.Portal>
{/* Base UI flips the popup above the button when there's no room below. */}
<Popover.Positioner sideOffset={8}>
{/* --transform-origin points at the arrow, so it grows out of the button. */}
<Popover.Popup className='relative w-65 origin-(--transform-origin) rounded-xl border bg-background p-4 shadow-lg outline-none transition-[opacity,scale] duration-150 ease-out data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0'>
<Popover.Arrow className='size-3 rotate-45 bg-background data-[side=bottom]:-top-1.5 data-[side=bottom]:border-t data-[side=bottom]:border-l data-[side=top]:-bottom-1.5 data-[side=top]:border-r data-[side=top]:border-b' />
<Popover.Title className='text-sm font-semibold'>
Share “Q3 roadmap”
</Popover.Title>
<form
className='mt-3 flex gap-2'
onSubmit={(event) => event.preventDefault()}
>
<input
type='email'
required
aria-label='Email'
placeholder='name@company.com'
className='h-9 min-w-0 flex-1 rounded-md border bg-background px-3 text-sm outline-none focus:ring-2 focus:ring-ring'
/>
<button className='h-9 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground'>
Invite
</button>
</form>
<label className='mt-4 flex items-center justify-between text-sm'>
Anyone with the link
<Switch.Root className='flex h-5 w-9 rounded-full bg-muted p-0.5 transition-colors data-checked:bg-blue-600'>
<Switch.Thumb className='size-4 rounded-full bg-white shadow-sm transition-transform data-checked:translate-x-4' />
</Switch.Root>
</label>
</Popover.Popup>
</Popover.Positioner>
</Popover.Portal>
</Popover.Root>
);
}Add a Share popover to the document header: clicking Share opens a 260px panel 8px below the button with a small arrow pointing at it, an email field with an Invite button, and an 'Anyone with the link' switch. Scale it in from 0.95 at the arrow over 150ms with an ease-out curve, flip it above the button when there isn't room below, close it on Escape or a click outside, and return focus to the Share button.
Paste into Layerwise or any AI coding tool.
What is Popover?
A popover opens right next to its trigger, usually with a small arrow pointing back at it, and floats above the page. It can hold real content: a short form, a color picker, sharing settings, or a calendar. Clicking outside or pressing Escape closes it, and the rest of the page keeps working.
Use a popover for quick, optional settings tied to one button. If the content is only a label, use a tooltip. If it is a list of actions, use a dropdown menu. If the task needs full attention or a decision before anything else, use a modal.
Place it below its button and flip it above when there is no room. Scale it in from the side nearest the button so it seems to grow out of it. The native HTML popover attribute handles stacking, Escape, and clicking outside, and CSS anchor positioning can pin it to its button in browsers that support it.
Often confused with
- Tooltip
- A tooltip shows a short label on hover or focus and holds nothing you can click. A popover opens on click and can hold inputs and buttons.
- Dropdown menu
- A dropdown menu is a list of actions to pick from. A popover holds other content, such as a small form or settings.
- Modal
- A modal blocks the whole page until you respond. A popover stays next to its button and closes as soon as you click elsewhere.
Related terms
All termsTooltip
A small label that appears next to an element when you hover over it or focus it, naming an icon button or adding a short hint.
Dropdown menu
A list of actions that drops down from a button when you click it, then closes as soon as you pick one.
Modal
A window that opens over the page, dims everything behind it, and blocks the rest of the interface until you finish or dismiss it.
Transform origin
The point an element rotates and scales around. It defaults to the center, and moving it changes where a transform seems to start.
Build it with Layerwise
Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.