Skip to Content
Cristal

Overlays

Hover card

Preview of a link that opens when the pointer lingers on it.

<cr-hover-card>CrHoverCard

Example

cr-hover-card wraps a link (a name, a page, a product) and shows a preview of its destination when the pointer lingers on it for half a second (openDelay, in milliseconds) or keyboard focus reaches it. The card content goes in slot="card".

Last edited by Mia Laurent
Mia Laurent
Product designer · Lyon

Owns the design system, 48 contributions this month.

, 3 hours ago.
'use client';

import { CrAvatar, CrBox, CrHoverCard } from '@cristal-ui/react';

export default function HoverCardBasic() {
  return (
    <div>
      Last edited by{' '}
      <CrHoverCard>
        <a href="#mia">Mia Laurent</a>
        <CrBox slot="card" display="flex" gap="lg" align="start">
          <CrAvatar name="Mia Laurent" status="online" />
          <div>
            <strong>Mia Laurent</strong>
            <div style={{ color: 'var(--cr-color-text-muted)' }}>Product designer · Lyon</div>
            <p style={{ margin: 'var(--cr-spacing-sm) 0 0' }}>Owns the design system, 48 contributions this month.</p>
          </div>
        </CrBox>
      </CrHoverCard>
      , 3 hours ago.
    </div>
  );
}

What goes in it

The card is a preview: everything it shows must also be found behind the link, since it cannot be seen with a finger and screen readers do not read it. It holds no button or link: they could not be reached with the keyboard. For a panel with actions, use a popover; for short help text, a tooltip.

If the user asked their system to reduce motion, the card appears directly, without unfolding.

Accessibility

  • The card opens on keyboard focus as on hover, and stays open while the pointer moves from the link to the card.
  • Escape closes it, wherever focus is; it also closes when focus leaves the link.
  • With a finger, a tap follows the link without opening the card.

API

Properties

PropertyTypeDefaultDescription
openDelaynumber500Délai avant l'ouverture au survol, en millisecondes : un simple passage du pointeur n'ouvre rien.

Slots

SlotDescription
defaultLe déclencheur, un lien en général.
slot="card"Le contenu de la carte, sans bouton ni lien (il ne serait pas atteignable au clavier).

CSS parts

To style it from outside: cr-hover-card::part(name) { … }

PartDescription
cardLa carte.

On this page