Tooltip
A short hint on hover and keyboard focus.
Focus the icon
Source
<script lang="ts">
import 'portal-bits/styles.css';
import 'portal-bits/tokens.css';
import type { Snippet } from 'svelte';
let { children }: { children: Snippet } = $props();
</script>
{@render children()}
<script lang="ts">
import TooltipExample from './TooltipExample.svelte';
</script>
<TooltipExample text={"short"} />
<script lang="ts">
import { Tooltip } from 'portal-bits';
let { text = 'short' }: { text?: 'short' | 'long' } = $props();
const messages = {
short: 'Keyboard navigation',
long: 'Every control in this library supports keyboard navigation',
};
</script>
<div class="row">
<Tooltip text={messages[text]}>
<svg
width="17"
height="17"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
><circle cx="12" cy="12" r="10" /><path d="M12 16v-4" /><path d="M12 8h.01" /></svg
>
</Tooltip>
<span>Focus the icon</span>
</div>
<style>
.row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 14px;
}
</style>
API reference
These tables list the props and snippets that Tooltip declares. Attributes passed through to an element or primitive are listed under Forwarded attributes, not here.
Props
| Name | Type | Default | Required | Binding | Description |
|---|---|---|---|---|---|
text | string | None | Yes | One-way | The tooltip text. It is also the trigger name. |
theme | 'light' | 'dark' | light | No | One-way | Theme scope for the portaled content. Portaled content does not inherit the page scope. |
Snippets
| Name | Type | Default | Required | Binding | Description |
|---|---|---|---|---|---|
children | Snippet | None | No | One-way | The trigger content, usually an icon. |
Forwarded attributes
None. Tooltip forwards no attributes.
The primitive underneath is a Bits UI peer dependency. Its own options are documented in the Bits UI Tooltip documentation. Only the props listed on this page are part of the Tooltip contract. No data attributes are documented as stable.
Limits
- The trigger is always a secondary 40px icon button. Do not use it to wrap other controls.
- Placement, delay, and Provider options are fixed: 8px offset and a 300ms open delay.
- Tooltip text is plain text. Do not put interactive content in it.