Keyframery

Tooltip

Pops out of its button, and switches instantly as you move to the next one.

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/tooltip

This adds components/keyframery/tooltip.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 { Tooltip, TooltipContent, TooltipTrigger } from "@/components/keyframery/tooltip"

export default function Usage() {
  return (
    <Tooltip>
      <TooltipTrigger>Hover</TooltipTrigger>
      <TooltipContent>Add to library</TooltipContent>
    </Tooltip>
  )
}

Anatomy

How the parts fit together:

Tooltip
├── TooltipTrigger
└── TooltipContent

Examples

Icon buttons

A tooltip names a button that only shows an icon. Once one is open, the next opens at once as you move along.

With a shortcut

shortcut on the tooltip shows the keys with TooltipShortcut and presses the trigger when they're pressed.

Placement

side picks where it appears. It flips when there isn't room.

Motion

MoveWhat you see
UnfoldThe tip pops out of its button.
FadeMoving to the next button switches instantly, with no second animation.

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

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

"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
--tooltip-faceTooltip surface and arrow--foreground
--tooltip-inkTooltip text and shortcut tint--background; 15% shortcut fill and 70% shortcut ink
--tooltip-radiusTooltip corners8px
--tooltip-fontTooltip text size12px
--tooltip-widthTooltip maximum width16rem
--tooltip-gapLabel-to-shortcut gap0.5rem

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 tooltip reference.

Tooltip

Prop

Type

TooltipTrigger

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

Prop

Type

TooltipContent

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

Prop

Type

TooltipShortcut

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

Prop

Type

Other parts

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

  • TooltipArrow: a <div>

Keyboard

KeyWhat it does
TabOpens the tooltip when its trigger gets focus.
EscapeCloses the tooltip.

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 tooltip with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.

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

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

Questions

How does the animated Tooltip for UI SDK move?

Unfold: The tip pops out of its button. Fade: Moving to the next button switches instantly, with no second animation.

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

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/tooltip instead. It has the same parts and props as @ui-sdk/react/tooltip and adds motion only.

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

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

All components

On this page