Overlays

Hover Card

A floating card that appears on hover, useful for previewing linked content.

Preview
01 Installation

Install

Pull Hover Card from the barrel for everyday use, or the granular path when you want a tighter bundle.

tsxBarrel1 line
import { HoverCard } from "@brika/clay";
tsxGranular1 line
import { HoverCard } from "@brika/clay/components/hover-card";
02 Usage

A minimal example

Drop this into a page. Native HTML attributes pass through to the underlying primitive.

tsxHover Card.tsx25 lines
import { Button } from '@brika/clay/components/button';
import {
  HoverCard,
  HoverCardContent,
  HoverCardTrigger,
} from '@brika/clay/components/hover-card';
/** Hover over an inline element to preview non-critical supplemental content. */
export default function HoverCardDefaultDemo() {
  return (
    <HoverCard>
      <HoverCardTrigger asChild>
        <Button variant="link">@brika</Button>
      </HoverCardTrigger>
      <HoverCardContent className="w-72">
        <div className="flex flex-col gap-1">
          <p className="font-semibold text-sm">Brika Labs</p>
          <p className="text-muted-foreground text-sm">
            Building Clay, the React component library and design system for Brika products.
          </p>
          <p className="text-muted-foreground text-xs">Joined January 2024</p>
        </div>
      </HoverCardContent>
    </HoverCard>
  );
}
03 Examples

Hover Card, every way

Delay

Open delay can be customised via the openDelay prop on HoverCard.

Profile

Rich profile preview with avatar, display name, handle, bio, and join date.

04 Accessibility

Accessibility

  • Content opens on hover AND focus, keyboard users can trigger it via Tab.
  • Not suitable for content that must be permanently reachable, use Popover for interactive content.
  • Ensure the trigger is keyboard-focusable; an asChild link or button works well.
05 Tokens 12 theme-overridable

Theme tokens

Every CSS variable Hover Card reads, with its default and the dotted path you'd write in a ThemeConfig JSON to override it. Set any of these in your theme to retune Hover Card without touching component code.

Hover Card tokens

12 tokens
ColorFill, border, and text colors.2
  • --hover-card-surface-containercolorvar(--popover)
    components.hoverCard.surfaceContainer

    Background of the hover-card surface.

  • --hover-card-surface-labelcolorvar(--popover-foreground)
    components.hoverCard.surfaceLabel

    Default foreground color inside the hover-card.

GeometrySizes, lengths, and corner radii.4
  • --hover-card-radiusradiusvar(--radius-surface)
    components.hoverCard.radius

    HoverCard corner radius.

  • --hover-card-padding-xsizecalc(var(--spacing) * 3)
    components.hoverCard.paddingX

    Inline padding inside the hover-card.

  • --hover-card-padding-ysizecalc(var(--spacing) * 3)
    components.hoverCard.paddingY

    Block padding inside the hover-card.

  • --hover-card-gapsizecalc(var(--spacing) * 2)
    components.hoverCard.gap

    Gap between adjacent children inside the hover-card.

BorderBorder width and style.2
  • --hover-card-border-widthborder-width1px
    components.hoverCard.borderWidth

    Border width on the hover-card. Set non-zero for outline-style variants.

  • --hover-card-border-styleborder-stylesolid
    components.hoverCard.borderStyle

    Border style on the hover-card (`solid`, `dashed`, `double`, `none`).

ElevationDrop shadow and depth.2
  • --hover-card-shadowshadowvar(--shadow-overlay)
    components.hoverCard.shadow

    HoverCard elevation.

  • --hover-card-backdrop-blurblur0px
    components.hoverCard.backdropBlur

    Backdrop blur on the hover card. Set non-zero for a frosted-glass surface.

MotionAnimation duration and easing.2
  • --hover-card-durationdurationvar(--motion-standard-duration)
    components.hoverCard.duration

    Transition duration for hover-card state changes.

  • --hover-card-easingeasingvar(--motion-standard-easing)
    components.hoverCard.easing

    Transition easing for hover-card state changes.

Override in a theme

Authoring a theme is plain JSON. Drop overrides under components.hoverCard, the names are camelCase versions of the variable suffix.

jsonmy-theme.json12 lines
{
  "id": "my-theme",
  "name": "My Theme",
  "description": "...",
  "accentSwatches": ["#000"],

  "components": {
    "hoverCard": {
      "paddingX": "calc(var(--spacing) * 3)"
    }
  }
}

Then apply with applyTheme(myTheme) (see the theming guide), scope it to a subtree with themeToCssVars(myTheme, mode), or consume any token directly in your own JSX with the matching Tailwind utility (e.g. bg-hover-card-…) — see the chips on each token row.

06 API reference

API reference

Props specific to Hover Card. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.

<HoverCard />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<HoverCardContent />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<HoverCardTrigger />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.