Keyframery

Popover

Unfolds from the button that opened it, then its contents cascade in.

See it as an AI agent does.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/popover

This adds components/keyframery/popover.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.

Usage

import { Popover, PopoverContent, PopoverTrigger } from "@/components/keyframery/popover"

export default function Usage() {
  return (
    <Popover>
      <PopoverTrigger>Open</PopoverTrigger>
      <PopoverContent>Content</PopoverContent>
    </Popover>
  )
}

Anatomy

How the parts fit together:

Popover
├── PopoverTrigger
└── PopoverContent

Examples

With a title and a form

A popover holds interactive content. Focus moves into it, and Escape or a click outside closes it.

Placement

side and align choose where it opens. It flips by itself when there isn't room.

Open on hover

openOnHover opens it while the pointer rests on the trigger, after delay. A click still opens it too.

Motion

MoveWhat you see
UnfoldThe popover unfolds from the button that opened it.
CascadeIts contents arrive one after another.

Timing and springiness follow the motion style you set. To change how fast this popover moves, pass speed:

<Popover speed="fast">
  …
</Popover>

"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.

Theming

Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.

VariableWhat it changesDefault
--popover-surfaceSheet and arrow--popover
--popover-inkSheet text--popover-foreground
--popover-mutedDescription and shortcut text--muted-foreground
--popover-keyTrigger and default close surface--background, --accent in dark
--popover-primaryPrimary close surface--primary
--popover-widthSheet width18rem
--popover-radiusSheet corners14px
--popover-paddingSheet padding1rem

API reference

Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK popover reference.

Popover

Prop

Type

PopoverTrigger

Renders a <button>, and takes its props too.

Prop

Type

PopoverContent

Renders a <div>, and takes its props too.

Prop

Type

PopoverClose

Renders a <button>, and takes its props too.

Prop

Type

PopoverShortcut

Renders a <span>, and takes its props too.

Prop

Type

Other parts

These take the props of the element they render, and nothing else:

  • PopoverArrow: a <div>
  • PopoverDescription: a <p>
  • PopoverTitle: a <h2>

Keyboard

KeyWhat it does
EnterOpens the popover from its trigger.
TabMoves through the popover's controls.
EscapeCloses the popover and returns focus to the trigger.

Accessibility

Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.

Swap the import

Already using UI SDK's popover with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.

// Before
import { … } from "@ui-sdk/react/popover"

// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/popover"

Questions

How does the animated Popover for UI SDK move?

Unfold: The popover unfolds from the button that opened it. Cascade: Its contents arrive one after another.

Do I need Motion or Framer Motion for the animated Popover?

No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.

Can I keep my own styling and only take the motion?

Yes. Import from @/components/keyframery/primitives/popover instead. It has the same parts and props as @ui-sdk/react/popover and adds motion only.

What happens to the Popover when someone turns on reduced motion?

Nothing moves. State changes happen at once, or with a short fade.

All components

On this page