Prodular UI

Point anchor

Anchors Tooltip, Popover and HoverCard to a point instead of a trigger: a map marker, a chart datum, a graph node or the pointer.

npx prodular-ui add point-anchor

Map markers

Hover a marker for a surface tooltip, click for a popover. The same sites are buttons below the map for keyboard and screen reader users.

Chart point

The tooltip follows the nearest datum of an SVG chart.

Anatomy

<Popover open={Boolean(site)} onOpenChange={(o) => !o && setSite(null)}>  <PopoverContent anchor={pointAnchor(x, y, mapRef.current)}>…</PopoverContent></Popover>

Guidance

Use it when

  • Overlays over canvas, WebGL, SVG or map content that has no DOM element per item.
  • pointAnchor(x, y, container) with coordinates relative to the canvas or map container.
  • A new anchor when the point moves, for example on the map's move event.

Avoid

  • Hand-positioned divs that copy popover styles. They miss collision handling, focus and dismissal.
  • Hover as the only way to reach the information. Offer the same items as a list or in an inspector.

Rules for AI agents

Published in llms-full.txt, the registry and the MCP server, so coding agents follow them when they build with this component.

  • Pass anchor to TooltipContent, PopoverContent or HoverCardContent; keep the Root controlled with open.
  • Use variant="surface" on tooltips over maps and dark canvases.
  • Provide a keyboard path to every marker: a list of buttons, the command palette or an inspector.
  • Build anchors with pointAnchor, rectAnchor or pointerAnchor from @/components/ui/point-anchor, not by hand.

API

pointAnchor

PropTypeDefaultDescription
(x, y, relativeTo?)VirtualAnchorA point, relative to an element when given.

rectAnchor

PropTypeDefaultDescription
(rect, relativeTo?)VirtualAnchorA rectangle such as a node's bounds.

pointerAnchor

PropTypeDefaultDescription
(event)VirtualAnchorThe pointer position of a mouse or pointer event.

TooltipContent

PropTypeDefaultDescription
anchorElement | VirtualAnchor | RefObjectAlso on PopoverContent and HoverCardContent.

Installation

The Prodular UI CLI adds the source to components/ui with everything it depends on. In a project that already uses shadcn/ui, the shadcn CLI installs it from the Prodular registry too. See Installation for the first setup.

npx prodular-ui add point-anchor# or, with the registry in components.jsonnpx shadcn@latest add @prodular/point-anchor