Tooltip
A short label shown on hover or focus.
import { Tooltip } from '@elluzion/iv-ui'; 01 Preview
Positions
The preferred side flips automatically when space runs out.
Source· svelte Show Hide
<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>02 Usage
- Wrap the trigger;
labelis the tooltip text and the child stays the trigger. delaydefaults to 300 ms; Escape hides an open tooltip.- Tooltips supplement a visible label; they never replace one.
03 Examples
Delay
A short delay for dense toolbars, a longer one for prose.
Source· svelte Show Hide
<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.
Source· svelte Show Hide
<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>04 API
import { Tooltip } from '@elluzion/iv-ui';Props
5 props · 0 events · 2 snippets| 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.
type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';05 Accessibility
| Keys | Action |
|---|---|
| Escape | Hides an open tooltip. |
- The wrapper points at the tooltip with
aria-describedbyonly 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.
06 Tokens & CSS hooks
Tokens used
Class hooks
.iv-ready.iv-root.iv-tooltip