Skip to the page
Supply UI

Hover card

In code: HoverCard

A small card that opens when a link is hovered or focused: a person, a record. Never the only way to reach the information.

Preview

Booked by Noor Haddad for Friday at 09:30.

Use

The code of the preview above
import { HoverCard, ItemText, PatternAvatar, Row } from '@/components/ui';

<p>
  Booked by{' '}
  <HoverCard
    content={
      <Row nowrap gap={3}>
        <PatternAvatar name="Noor Haddad" />
        <ItemText title="Noor Haddad" note="12 visits since March, usually on Fridays" />
      </Row>
    }
  >
    <a className="ui-link" href="#clients">Noor Haddad</a>
  </HoverCard>{' '}
  for Friday at 09:30.
</p>

This page as text, for an AI

Options

OptionTypeWhat it does
children NeededReactElement<Record<string, unknown>, string | JSXElementConstructor<any>>The link the card belongs to.
content NeededReactNodeWhat shows in the card: a short summary of what the link leads to.

Without React

With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:

components/button.csscomponents/card.csscomponents/table.csscomponents/tabs.csscomponents/popups.csscomponents/dialog.csscomponents/icons.csscomponents/input-group.csscomponents/calendar.csscomponents/button-group-toggle.csscomponents/code-input.csscomponents/tab-bar.csscomponents/command-palette.csscomponents/prose.csscomponents/carousel-arrows.csscomponents/page-transitions.cssparts/carousel.cssparts/calendar.cssparts/date-time-typed-part.cssparts/listbox.cssparts/date-picker.cssparts/board.css

In the examples

Small screens made with it and the rest of the kit. They work: click, type and choose in them.

Saturday

Hover a name to see who it is

Who is on today A name opens a card about the person

On top of the page: states, do and don’t

A small card when a link is hovered or focused: a person, a record. Never the only way to the information.

States. Closed, opening (fades and rises), open, closing (fades before what it changed appears: afterClose). While open, focus is inside and Escape closes it; when it closes, focus goes back to what opened it.

Do

  • Name every dialog, drawer and popover (DialogTitle, DrawerTitle, or aria-label).
  • Use AlertDialog for anything that cannot be undone, with the action named on its button ("Delete 3 files").
  • Use a Drawer on a phone for what a Popover does on a computer.

Don't

  • Don't open a dialog from a dialog; change what the open one shows instead.
  • Don't put the only way to do something in a right-click menu or a tooltip.
  • Don't use a toast for something the person must not miss: that is an Alert on the page.