Skip to content

Animated Tooltip

Motion

React row of overlapping avatars where hovering or focusing one pops up a name and role card that tilts and slides with the pointer on springs.

src/registry/premium/animated-tooltip.tsx/r/animated-tooltip.json

Installation

bash
npx shadcn@latest add @minidev/animated-tooltip

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/animated-tooltip.json

Usage

tsx
import { AnimatedTooltip } from "@/components/ui/animated-tooltip"

export function Example() {
  return (
    <AnimatedTooltip />
  )
}

API reference

AnimatedTooltip props
PropTypeDefault
peoplePeople to show, left to right. Defaults to a five-person sample team.AnimatedTooltipPerson[]-
sizeAvatar diameter in pixels.number44
defaultActiveIndex of a card to show before any hover. Defaults to the second person for the built-in sample only.number-
onSelectCalled when an avatar is clicked or activated with the keyboard.(person: AnimatedTooltipPerson, index: number) => void-
classNamestring-

When to use

The card rises on a spring, tilts a few degrees toward the pointer as it crosses the face, and settles back when it leaves. Keyboard focus opens the same card centred; Escape closes it; a tap toggles it on touch. Reduced motion shows and hides the card instantly with no tilt. Use it for team, contributor or "who's online" rows; for a tooltip on any trigger use Tooltip, and for a plain stacked row use AvatarGroup.

Keyboard interactions

Keyboard interactions
KeyAction
TaborShiftTabMoves between avatars. Focusing one opens its card, centred with no tilt.
EscapeCloses the open card; focus stays on the avatar.
EnterorSpaceActivates the focused avatar and calls onSelect.

Accessibility

  • Each avatar is a <button> with aria-label "{name}, {role}", such as "Theo Okafor, Head of Engineering".
  • The card has role="tooltip" but is aria-hidden, because the button's label already carries the same text.
  • Under reduced motion the card shows and hides with no rise or tilt, and avatars do not grow on hover.

Frequently asked questions

How do I show photos instead of initials?

Pass src for each person. The image has alt="" because the button's aria-label already names the person. Without src, initials come from the first two words of name, or from initials.

Why is the second person's card open on load?

Only with the built-in sample team: defaultActive falls back to 1 so the preview shows a card. When you pass people, no card opens until hover or focus, unless you set defaultActive.

How does it behave on touch screens?

A tap opens the card and a second tap on the same avatar closes it. The lean and slide follow a mouse pointer only. onSelect fires on every tap or click.

Dependencies

npm

motion

Built from

No other MiniDev files

Examples

Custom team

Pass people with a name and a role; initials come from the name when there is no image.

Large avatars

size sets the diameter in pixels; initials overrides the letters taken from the name.

Select handler

onSelect fires on click or Enter with the person and their index, so the row can double as a picker.

All dialog, drawer and popover components

Learn more