GooseUI

Components

Hint

New

A tiny text label beside an element, shown on hover and keyboard focus. Like the title attribute, but styled, positioned and animated. The browser does the work: no JavaScript opens it.

Browser Support

Interest invokers

The interestfor attribute on a button or link opens the hint on hover, keyboard focus and long press, after a delay. Without it, plain CSS shows the hint on :hover and :focus-visible.

Your browser:
popover="hint"

popover="hint" puts the label in the top layer, above everything, and closes on Escape without touching other popovers.

Your browser:
Anchor positioning

Places the hint beside the element and flips it to the other side when it would leave the screen. Without it the hint is placed with plain absolute positioning.

Your browser:

Preview

Hover an icon or Tab to it.

CopyDeleteShare

Installation

npx shadcn@latest add @gooseui/hint
pnpm dlx shadcn@latest add @gooseui/hint
yarn dlx shadcn@latest add @gooseui/hint
bunx --bun shadcn@latest add @gooseui/hint

Usage

Wrap one element. Give an icon-only button its own aria-label: the hint describes the element, it does not name it.

import { Copy } from "lucide-react"
import { Hint } from "@/components/ui/hint"

<Hint content="Copy">
  <button type="button" aria-label="Copy">
    <Copy />
  </button>
</Hint>

Examples

Sides

side picks where the hint appears. It flips to the opposite side when there is no room.

AboveBelowTo the leftTo the right
<Hint content="Below" side="bottom">
  <button type="button">bottom</button>
</Hint>

Truncated text

A line cut with an ellipsis shows its full text in the hint. The trigger is a plain span, so the hint is driven by CSS hover here. Add tabIndex={0} if keyboard users need it too.

Quarterly report: revenue, churn and the long tail of enterprise contracts.pdfQuarterly report: revenue, churn and the long tail of enterprise contracts.pdf
<Hint content={fileName} side="bottom">
  <span className="block min-w-0 truncate">{fileName}</span>
</Hint>

Hint and title

The title attribute is slow, cannot be styled, never shows on keyboard focus and does nothing on touch. Hint shows the same text consistently.

Copy the link
<Hint content="Copy the link">
  <button type="button">Hint</button>
</Hint>

<button type="button" title="Copy the link">title attribute</button>

Props

PropTypeDefaultDescription
contentstring-Hint text. Plain text, nothing interactive.
childrenReactElement-One element that gets the hint. A button or link opens it natively, any other element uses CSS hover.
side"top" | "bottom" | "left" | "right""top"Which side of the element the hint appears on.
delaynumber500Delay before the hint appears, in ms. A system tooltip waits about 500.
classNamestring-Extra classes for the hint bubble.

Features

  • Native first — interestfor and popover="hint" in the browser that has them: top layer, delay, Escape and cleanup come from the platform.
  • No double tooltip — The title attribute is never added, so no browser shows two hints. Browsers without interestfor get the same bubble from CSS.
  • Accessible — The element gets aria-describedby, the bubble has role="tooltip", Escape hides it in both modes and it never takes clicks.
  • Touch — Browsers with interestfor open the hint on long press. In the CSS mode a tap shows nothing, because a sticky hover on touch is worse than no hint.