Skip to content
Klarhimmel UI

Hover card

Guests love Room 311 for a quiet weekend.

npx shadcn add @klarhimmel/hover-card @klarhimmel/text-link

Examples

  • Basic

  • Person

  • Controlled

DetailsAbout, usage, props and more

A preview of where a link goes, shown on hover and on keyboard focus, never the only copy.

When to use

  • Use for

    A short preview of where a link goes: a room, a person, a rate.

  • Not for

    Anything only available in the card. Touch screens never open it. Actions. Use Popover.

  • Pairs with

    Text link, Avatar.

Preview

Guests love Room 311 for a quiet weekend.

Hover the link, or Tab to it: the preview opens on focus too. Escape closes it.

hover-card.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { HoverCard } from '@/components/klarhimmel/ui/hover-card';
import { TextLink } from '@/components/klarhimmel/ui/text-link';

export default function Example() {
  return (
    <Theme theme="brand">
      <HoverCard trigger={<TextLink href="#room-311">Room 311</TextLink>}>
        A double room with a balcony. From 1 490 kr a night.
      </HoverCard>
    </Theme>
  );
}

Import

Import

import { HoverCard } from '@/components/klarhimmel/ui/hover-card';
Files
hover-card.tsx, text-link.tsx, in components/klarhimmel/ui/. With it: button, theme, utils. npm: radix-ui.
Render in
Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Limit
Overlays render into the Theme root with position: fixed. A transform on an ancestor re-parents fixed (a dialog centres in the wrapper) and overflow: hidden clips menus. Render <Theme> at the app root, outside any transformed wrapper.

Props

PropTypeDefaultDescription
triggerReactElementrequiredThe link or button that opens it. One element: it receives the card's description and keeps its own name.
childrenReactNoderequiredThe preview. Plain content only: no buttons or links, because pointer and keyboard users cannot reach into it, and a touch screen never shows it.
openboolean-Controlled or uncontrolled.
defaultOpenboolean-Controlled or uncontrolled.
onOpenChange(open: boolean) => void-Controlled or uncontrolled.
openDelaynumber500Milliseconds before it opens and before it closes. Default 500 and 200.
closeDelaynumber200Milliseconds before it opens and closes.
align'start' | 'center' | 'end''center'Where it sits against the trigger.
classNamestring-Extra classes, merged after the component's own.

Accessibility

KeyDoes
TabFocusing the link opens the card; leaving closes it
EscapeCloses it
EnterFollows the link, as always

While open the card is the trigger's aria-describedby. It holds plain content: nothing in it can be reached by keyboard.

Accessibility