Cloud|

@k2b/ui

Tooltip

Concise accessible hints with viewport-aware positioning.

Tooltip@k2b/ui

Buttons own their tooltip directly. Tooltip.Anchor is the explicit target for non-button content. Long content wraps, remeasures, and stays clamped inside the viewport.

Copy the public URLLong edge hintA longer explanation wraps before its final viewport position is calculated.

TSX

Copy
<Button variant="secondary" tooltip="Copy the public URL">
Share
</Button>
<Tooltip.Anchor
placement="bottom"
content="A longer explanation wraps before its final viewport position is calculated."
>
<span tabindex="0">Non-button target</span>
</Tooltip.Anchor>

Tooltip adds a concise, non-interactive hint to an existing control. It opens for pointer hover and keyboard focus and keeps the surface inside the viewport.

Use Tooltip

Use it to explain an icon-only or unfamiliar control.

Keep essential instructions and validation messages visible in the page. Use a popover or dialog when the content contains links, buttons, or other interaction.

Import

tsx
import {
  IconButton,
  Tooltip,
  type TooltipPlacement,
} from "@k2b/ui";

Contracts

Buttons expose tooltip properties directly:

Property Type Default Purpose
tooltip JSX.Element | false none Supplies the non-interactive hint.
tooltipPlacement "top" | "bottom" "top" Requests the preferred vertical placement.
tooltipDelay number 250 Sets the open delay in milliseconds.

Use Tooltip.Anchor as an explicit wrapper for non-button content. It accepts content, placement, delay, disabled, and ordinary span attributes. Use Tooltip.Trigger only for a specialized native button that does not use the shared Button components. Neither contract searches or rewrites descendant DOM.

Placement is a preference. The surface flips vertically when the requested side does not fit and clamps horizontally to the viewport. Positioning measures twice: it first fixes the available horizontal position, then remeasures wrapped content before calculating the final top and left coordinates.

Accessibility

The target receives aria-describedby after hydration. Keep the control's own accessible name; a tooltip description does not replace aria-label.

Tooltips open on focus as well as hover. Escape dismisses the current hint. Pointer down, pointer leave, focus out, scrolling, and resizing also close it.

Keep content short and non-interactive. Do not communicate required state through a tooltip alone.

Runtime

The target and tooltip surface render on the server. Hydration attaches aria-describedby to the explicitly owned target, opens the Popover API surface, positions it, and handles dismissal.

Long content wraps to the surface maximum width. Keep it concise even though the second measurement prevents wrapping from producing stale vertical placement.

Example

tsx
<IconButton label="Settings" tooltip="Application settings">
  <i class="ti ti-settings" aria-hidden="true" />
</IconButton>

<Tooltip.Anchor
  placement="bottom"
  content="This longer explanation wraps and remains inside the viewport."
>
  <span tabindex="0">Focus or hover</span>
</Tooltip.Anchor>

Connect a coding agent

The Cloud skill provides compact working instructions. MCP supplies exact current documentation when details matter.

CLI command
bunx skills add https://docs.example.com

This command installs the working instructions published by this website in the selected coding agent.

For exact, current details, also connect the MCP server through one of the agent tabs.

Installation uses the open-source Vercel Skills CLI.

The skill and MCP complement each other: the skill describes workflows, while MCP supplies current documentation.