---
title: "Tooltip"
description: "A short label shown on hover or focus."
category: "Overlays"
slug: tooltip
url: /components/tooltip
since: "0.2.0"
status: "stable"
---

# Tooltip

A short label shown on hover or focus.

## Import

```svelte
import { Tooltip } from '@elluzion/iv-ui';
```

## Preview

The preferred side flips automatically when space runs out.

```svelte
<script lang="ts">
	import { Button, Tooltip } from '@elluzion/iv-ui';
</script>

<div class="row">
	{#each ['top', 'bottom', 'left', 'right'] as side (side)}
		<Tooltip label="{side} tooltip" position={side as 'top' | 'bottom' | 'left' | 'right'}>
			<Button variant="outline" size="sm">{side}</Button>
		</Tooltip>
	{/each}
</div>

<style>
	.row {
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		gap: var(--iv_spacing-sm);
	}
</style>
```

## Usage

- Wrap the trigger; `label` is the tooltip text and the child stays the trigger.
- `delay` defaults to 300 ms; Escape hides an open tooltip.
- Tooltips supplement a visible label; they never replace one.

## Examples

### Delay

A short delay for dense toolbars, a longer one for prose.

```svelte
<script lang="ts">
	import { Button, Tooltip } from '@elluzion/iv-ui';
</script>

<div class="row">
	<Tooltip label="Opens immediately" delay={0}>
		<Button variant="outline" size="sm">No delay</Button>
	</Tooltip>
	<Tooltip label="Opens after 700 ms" delay={700}>
		<Button variant="outline" size="sm">Long delay</Button>
	</Tooltip>
</div>

<style>
	.row {
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		gap: var(--iv_spacing-sm);
	}
</style>
```

### Custom content

The `content` snippet can hold a shortcut, a hint, or both.

```svelte
<script lang="ts">
	import { Button, Shortcut, Tooltip } from '@elluzion/iv-ui';
</script>

<Tooltip position="bottom">
	{#snippet content()}
		<span class="content">Command palette <Shortcut keys={['⌘', 'K']} /></span>
	{/snippet}
	<Button variant="outline" size="sm">Open palette</Button>
</Tooltip>

<style>
	.content {
		display: inline-flex;
		align-items: center;
		gap: var(--iv_spacing-sm);
	}
</style>
```

### Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` | `''` | Tooltip text. |
| `position` | `TooltipPosition` | `'top'` | Preferred side of the trigger. |
| `delay` | `number` | `300` | Delay before showing, in milliseconds. |
| `disabled` | `boolean` | `false` | Disables interaction and applies the disabled treatment. |
| `className` | `string` | `''` | Extra classes merged onto the root element. |

### Snippets

| Snippet | Type | Description |
| --- | --- | --- |
| `content` | `Snippet` | Custom tooltip content replacing the label. |
| `children` | `Snippet` | The trigger element. |

### Types

#### `TooltipPosition`

Side of the trigger the tooltip prefers.

```ts
type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
```

### Tokens used

`--iv_border-hover` · `--iv_font-mono` · `--iv_foreground` · `--iv_leading-tight` · `--iv_radius-sm` · `--iv_shadow-md` · `--iv_spacing-md` · `--iv_spacing-xs` · `--iv_surface-elevated` · `--iv_text-body-sm` · `--iv_z-dropdown`

See the [token reference](/foundations/tokens.md) for values.

### CSS hooks

`.iv-ready` · `.iv-root` · `.iv-tooltip`

## Accessibility

| Keys | Action |
| --- | --- |
| `Escape` | Hides an open tooltip. |

- The wrapper points at the tooltip with `aria-describedby` only while it is visible.
- Focus and hover both open the tooltip; leaving or blurring closes it.
- Touch devices do not show hover tooltips, so keep the information available in the interface.

## Related

- [Popover](/components/popover.md)
- [Shortcut](/components/shortcut.md)
- [Menu](/components/menu.md)
- [Button](/components/button.md)