Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Event Preview Hover Card for Ark UI

Team Planning Session opens a card with an Upcoming badge, a short description, the date, a 90 minute slot, and 12 attendees.

The trigger is the name Team Planning Session. The card adds an Upcoming badge, a description of the quarterly planning meeting, Monday, January 15, 2024, 2:00 PM to 3:30 PM, and 12 attendees.

It belongs on a calendar or an agenda when the name is not enough. Touch screens have no hover, so a Popover is the stand-in. In React, Ark UI keeps the card open while the pointer moves onto it.

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.

Anatomy

Hover Card anatomy: trigger, positioner, arrow, content

Usage

<HoverCard>
  <HoverCardTrigger asChild>
    <button
      className="font-medium text-sm underline underline-offset-4"
      type="button"
    >
      Team Planning Session
    </button>
  </HoverCardTrigger>
  <HoverCardContent className="w-80">
    <div className="flex flex-col gap-3">
      <div className="flex items-center justify-between">
        <h4 className="font-semibold text-sm">Team Planning Session</h4>
        <Badge variant="secondary">Upcoming</Badge>
      </div>
      <p className="text-muted-foreground text-sm">
        Quarterly planning meeting to discuss goals, priorities, and team
        alignment for Q1.
      </p>
      <div className="flex flex-col gap-2 text-muted-foreground text-sm">
        <div className="flex items-center gap-2">
          <CalendarIcon aria-hidden="true" className="size-4" />
          <span>Monday, January 15, 2024</span>
        </div>
        <div className="flex items-center gap-2">
          <ClockIcon aria-hidden="true" className="size-4" />
          <span>2:00 PM - 3:30 PM (90 min)</span>
        </div>
        <div className="flex items-center gap-2">
          <UsersIcon aria-hidden="true" className="size-4" />
          <span>12 attendees</span>
{/* The rest of the file is under Installation. */}

FAQ

What is in the card?

The title with an Upcoming Badge, the description, then a calendar, a clock and a people icon, each beside its detail: Monday, January 15, 2024, 2:00 PM - 3:30 PM (90 min) and 12 attendees.

How is the event name made the trigger?

HoverCardTrigger takes asChild, and the demo passes the event name, a button.

How wide is the card?

w-80 on the card, for the extra content. The class is on HoverCardContent.

How do I change how fast the card opens and closes?

The card opens a moment after the pointer rests on the trigger and stays up long enough for the pointer to move into it. Both delays are in milliseconds. Set openDelay and closeDelay on HoverCard; they default to 10 and 100. positioning picks another side than the bottom.

Does the card open from the keyboard and on touch screens?

Focusing the event name opens the card, moving focus away or pressing Escape closes it. Touch screens have no hover, so keep what matters reachable elsewhere, or use a Popover when the card has to open on a tap.

API Reference

Hover Card

Sets asChild. The rest is on the Hover Card page.

Badge

Sets variant="secondary". The rest is on the Badge page.