Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Overlays

Hover card

A preview card that appears after a short hover over a link or name.

Selector: mui-hover-card

Import
import { HoverCard, HoverCardTrigger, HoverCardContent } from '@mushilu-san/ui/overlays';
PreviewCode

Loading example…

Overview

Hover card shows a mui-hover-card-content preview when the pointer rests on a muiHoverCardTrigger. openDelay and closeDelay set how long to wait, in milliseconds, so the card does not flicker.

The content has role="tooltip", and the trigger is linked to it while it is open. It is for a preview; the trigger is still a normal link.

When to use

  • A quick preview of a person, page or item behind a link.
  • Extra context that a user may want, but does not need to read.

When not to use

  • Content the user must read or act on. A hover card is not reachable on touch. Use Popover instead.
  • A one-line hint. Use a tooltip. Use Tooltip instead.

Guidelines

Do

  • Keep the trigger a real link, so the page works without the preview.
  • Put the same information on the linked page.

Don't

  • Do not put forms or buttons inside a hover card.

Accessibility

Roles and attributes

ElementRoleNotes
contenttooltipLinked from the trigger while it is open.
trigger—Keeps its own role, such as link.

Keyboard

KeysAction
FocusShows the card on the focused trigger.
EscapeHides the card.
  • Hover cards are not reachable by touch. The linked page must hold the same information.

API

HoverCard

Selector: mui-hover-card

NameTypeDefaultDescription
placement'start' | 'end' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left' | 'right' | 'top' | 'bottom' | 'left-start' | 'left-end' | 'right-start' | 'right-end''bottom' Side of the trigger the card opens on. Default `bottom`.
openDelaynumber700 Milliseconds to wait after the pointer arrives before opening. Default `700`.
closeDelaynumber300 Milliseconds to wait after the pointer leaves before closing. Default `300`.
NameTypeDefaultDescription
openbooleanfalse Whether the card is open. Two-way bindable with `[(open)]`.
NameTypeDescription
openedvoid Emits when the card opens.
closedvoid Emits when the card closes.

CSS parts

  • ::part(root)

HoverCardTrigger

Selector: [muiHoverCardTrigger]

CSS parts

  • ::part(trigger)

HoverCardContent

Selector: mui-hover-card-content

CSS parts

  • ::part(content)
  • ::part(panel)

Tokens

  • --mui-color-surface-raised
  • --mui-color-border
  • --mui-shadow-3
  • --mui-radius-md