Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Tooltip on Icon for Svelte

A small round button with an info icon and no visible words. Its tooltip reads More information.

UI library: Ark UI

A small round ghost button shows an info icon and no visible label. Its tooltip reads More information.

Use an icon button plus a tooltip when there is no room for a word. A visible label on a Button needs no tooltip. On Svelte, Ark UI does not name the button from the icon.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Tooltip anatomy: content, positioner, arrow, trigger

Usage

<Tooltip><TooltipTrigger>{#snippet asChild(props)}<Button {...props({ "aria-label": "More information" })} pill size="icon-sm" variant="ghost"><InfoIcon aria-hidden="true" class="text-muted-foreground" /></Button>{/snippet}</TooltipTrigger><TooltipContent><p>More information</p></TooltipContent></Tooltip>

FAQ

When should I use an icon tooltip?

For a short hint on a control that has no room for a label. This demo is an info icon on a round ghost button, and the tooltip repeats More information.

Why is the trigger a round ghost button?

pill makes the Button round. variant="ghost" draws no border or fill until hover, and size="icon-sm" sets a size-8 square.

How big is the info icon?

InfoIcon has no size class, so the button draws it at size-4. text-muted-foreground is the only color on the glyph.

Does an icon-only trigger need an accessible name?

Yes. The icon is aria-hidden="true", so the Button carries aria-label="More information". The tooltip shows that same sentence.

Where does the tooltip text live?

The paragraph More information is the tooltip body. It sits inside TooltipContent.

Which side does this tooltip open on?

The top, which is the default, and it flips when there is not enough room. Pass positioning with a placement such as bottom to Tooltip to pin another side.

API Reference

Tooltip

No extra props in this demo. The rest is on the Tooltip page.

Button

Sets props, aria-label, More, information, pill and size="icon-sm". The rest is on the Button page.