Tooltip

Tooltip displays contextual information when a user hovers over or focuses a trigger element.

tsx
import { RiShareLine } from '@remixicon/react';
import { IconButton } from '@/components/ui/wideset/button/IconButton';
import { Tooltip } from '@/components/ui/wideset/tooltip/Tooltip';

<Tooltip>
  <Tooltip.Trigger asChild>
    <IconButton icon={RiShareLine} variant="secondary" preset="border" aria-label="Share" />
  </Tooltip.Trigger>
  <Tooltip.Content>
    <Tooltip.Label>Share link</Tooltip.Label>
  </Tooltip.Content>
</Tooltip>

Installation

pnpm dlx wideset add tooltip

Copies the component and any Wideset components it uses into your project.

Examples

Variants

default is a dark tooltip for light screens; inverse is a light one for dark or coloured surfaces, where a dark tooltip would blend in. Pick by the background behind the trigger, not by importance. Both are drawn open here with open; in an app leave it out, and the tooltip shows on hover and keyboard focus. Screen readers announce it as the trigger's description, so an icon-only trigger still needs its own aria-label.

tsx
import { RiDownloadLine, RiShareLine } from '@remixicon/react';
import { IconButton } from '@/components/ui/wideset/button/IconButton';
import { Tooltip } from '@/components/ui/wideset/tooltip/Tooltip';

export default function TooltipVariants() {
  return (
    <div className="gap-ws-20 py-ws-5 flex w-[22rem] max-w-full flex-col">
      <Tooltip variant="default" open>
        <Tooltip.Trigger asChild>
          <IconButton icon={RiShareLine} variant="secondary" preset="border" aria-label="Share" />
        </Tooltip.Trigger>
        <Tooltip.Content side="right">
          <Tooltip.Label>Share link</Tooltip.Label>
          <Tooltip.Description>Anyone with the link can view this file.</Tooltip.Description>
        </Tooltip.Content>
      </Tooltip>
      <Tooltip variant="inverse" open>
        <Tooltip.Trigger asChild>
          <IconButton
            icon={RiDownloadLine}
            variant="secondary"
            preset="border"
            aria-label="Download"
          />
        </Tooltip.Trigger>
        <Tooltip.Content side="right">
          <Tooltip.Label>Download</Tooltip.Label>
          <Tooltip.Description>Saves Invoice #1042 as a PDF.</Tooltip.Description>
        </Tooltip.Content>
      </Tooltip>
    </div>
  );
}

Sizes

md is the default, with body-size text. sm uses caption-size text and less padding, for dense toolbars and tables where a larger tooltip would cover the row it explains. Use one size per screen. Both are drawn open here with open; in an app leave it out, and the tooltip shows on hover and keyboard focus.

tsx
import { RiFilter3Line, RiShareLine } from '@remixicon/react';
import { IconButton } from '@/components/ui/wideset/button/IconButton';
import { Tooltip } from '@/components/ui/wideset/tooltip/Tooltip';

export default function TooltipSizes() {
  return (
    <div className="gap-ws-20 py-ws-5 flex w-[22rem] max-w-full flex-col">
      <Tooltip size="md" open>
        <Tooltip.Trigger asChild>
          <IconButton icon={RiShareLine} variant="secondary" preset="border" aria-label="Share" />
        </Tooltip.Trigger>
        <Tooltip.Content side="right">
          <Tooltip.Label>Share link</Tooltip.Label>
          <Tooltip.Description>Anyone with the link can view this file.</Tooltip.Description>
        </Tooltip.Content>
      </Tooltip>
      <Tooltip size="sm" open>
        <Tooltip.Trigger asChild>
          <IconButton
            icon={RiFilter3Line}
            variant="secondary"
            preset="border"
            aria-label="Filter"
          />
        </Tooltip.Trigger>
        <Tooltip.Content side="right">
          <Tooltip.Label>Filter</Tooltip.Label>
          <Tooltip.Description>Show only unpaid invoices.</Tooltip.Description>
        </Tooltip.Content>
      </Tooltip>
    </div>
  );
}

API reference

Tooltip

NameDescriptionDefault
arrow

Shows a directional arrow pointing at the trigger.

boolean
true
children

Content rendered inside the component.

ReactNode
—
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
delayDuration

The duration from when the pointer enters the trigger until the tooltip gets opened. This will override the prop with the same name passed to Provider. Milliseconds before the tooltip appears after hover.

number
700
size

Size of the tooltip text. `md` uses body typography, `sm` uses caption typography.

TooltipSize
'md'
variant

Visual variant — `default` suits light surfaces; `inverse` suits dark or colored surfaces.

TooltipVariant
'default'
Every other prop of Radix Tooltip.Root is passed through to it. See Radix Tooltip.Root.

Tooltip.Arrow

No props of its ownIt takes its content as children.
Every other prop of Radix Tooltip.Arrow is passed through to it. See Radix Tooltip.Arrow.

Tooltip.Content

NameDescriptionDefault
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
portalContainer

DOM node to portal the content into. Defaults to `document.body`.

Element | DocumentFragment
—
Every other prop of Radix Tooltip.Content is passed through to it. See Radix Tooltip.Content.

Tooltip.Description

No props of its ownIt takes its content as children.
Every other prop of <p> is passed through to it. See MDN: <p>.

Tooltip.Label

No props of its ownIt takes its content as children.
Every other prop of <span> is passed through to it. See MDN: <span>.

Tooltip.Portal

No props of its ownIt takes its content as children.
Every other prop of Radix Tooltip.Portal is passed through to it. See Radix Tooltip.Portal.

Tooltip.Trigger

No props of its ownIt takes its content as children.
Every other prop of Radix Tooltip.Trigger is passed through to it. See Radix Tooltip.Trigger.

Accessibility

  • The tooltip is announced as the trigger’s description, not its name: an icon-only trigger still needs its own aria-label.
  • The trigger must be focusable (a button, link or IconButton), so keyboard users get the hint.
  • Never hide information users need only in a tooltip.
PartRendersDescription
TooltipRadix Tooltip.RootSupplementary information anchored to a trigger.
Tooltip.ArrowRadix Tooltip.ArrowProps for the internal tooltip arrow element.
Tooltip.ContentRadix Tooltip.ContentThe floating surface that wraps label and description.
Tooltip.Description<p>Supporting text rendered below the label.
Tooltip.Label<span>Bold title text rendered inside the tooltip.
Tooltip.PortalRadix Tooltip.PortalProps for `Tooltip.Portal`.
Tooltip.TriggerRadix Tooltip.TriggerThe element the tooltip is anchored to.
tsx
import { RiShareLine } from '@remixicon/react';
import { IconButton } from '@/components/ui/wideset/button/IconButton';
import { Tooltip } from '@/components/ui/wideset/tooltip/Tooltip';

<Tooltip>
  <Tooltip.Trigger asChild>
    <IconButton icon={RiShareLine} variant="secondary" preset="border" aria-label="Share" />
  </Tooltip.Trigger>
  <Tooltip.Content>
    <Tooltip.Label>Share link</Tooltip.Label>
  </Tooltip.Content>
</Tooltip>

Appearance

Variant
Size
Arrow
Side

Content

Description