Tooltip
Tooltip displays contextual information when a user hovers over or focuses a trigger element.
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.
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.
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
| Name | Description | Default |
|---|---|---|
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' |
Radix Tooltip.Root is passed through to it. See Radix Tooltip.Root.Tooltip.Arrow
Radix Tooltip.Arrow is passed through to it. See Radix Tooltip.Arrow.Tooltip.Content
| Name | Description | Default |
|---|---|---|
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 | — |
Radix Tooltip.Content is passed through to it. See Radix Tooltip.Content.Tooltip.Description
<p> is passed through to it. See MDN: <p>.Tooltip.Label
<span> is passed through to it. See MDN: <span>.Tooltip.Portal
Radix Tooltip.Portal is passed through to it. See Radix Tooltip.Portal.Tooltip.Trigger
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.
| Part | Renders | Description |
|---|---|---|
| TooltipRenders no element | Radix Tooltip.Root | Supplementary information anchored to a trigger. |
| Tooltip.ArrowRenders no element | Radix Tooltip.Arrow | Props for the internal tooltip arrow element. |
| Tooltip.ContentRenders no element | Radix Tooltip.Content | The floating surface that wraps label and description. |
| Tooltip.DescriptionRenders no element | <p> | Supporting text rendered below the label. |
| Tooltip.LabelRenders no element | <span> | Bold title text rendered inside the tooltip. |
| Tooltip.PortalRenders no element | Radix Tooltip.Portal | Props for `Tooltip.Portal`. |
| Tooltip.TriggerRenders no element | Radix Tooltip.Trigger | The element the tooltip is anchored to. |
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>