Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Popover examples · Standard

User Profile Popover for React

A username button that opens a popover with the person's name, handle and role.

Framework
UI library

A ghost @username button that opens the person's name, handle and role. Show who someone is without leaving the page; for a preview on hover, use a Hover Card. In React, Base UI handles opening, dismissing and focus.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

What does the profile panel show?

PopoverHeader holds PopoverTitle reading John Doe and PopoverDescription reading @username. Under that, a p with text-xs says Software Developer. The trigger label is @username.

How does the username button open the panel?

The trigger is a Button with variant="ghost" and the label @username. Pressing it, or using Enter or Space, opens the panel. For a preview that opens when the pointer rests on a name, use a Hover Card. Pass the button to render on PopoverTrigger, and use PopoverContent as the panel.

Which text styles separate the name, handle, and role?

The name is PopoverTitle. The handle is PopoverDescription, inside PopoverHeader. The role is a separate p with className="text-xs".

How wide is the profile panel?

PopoverContent has no width class, so it keeps w-72. The content is the header plus the one-line role.

How does this panel dismiss?

Escape closes the panel and returns focus to the trigger. A click outside closes it too. The panel sits beside the button, and the rest of the page stays usable.

Does the button text match the handle in the panel?

The button and PopoverDescription both say @username. PopoverTitle says John Doe. The role line says Software Developer.