Skip to content
portalbits
Home Docs GitHub(opens in a new tab)

Guides

Get startedFoundationsMotion

Components

All components

Buttons

ButtonIconButton

Inputs

InputSelectTextareaSlider

Selection

CheckboxToggleToggleGroupSwitchRadioGroup

Identity

AvatarBadge

Overlays

DialogPopoverTooltipDropdownMenuAlertDialog

Disclosure

TabsAccordion

Cards

AppCardArticleCardFeatureCard

Content

CarouselSectionHeaderEmptyStateAlertProgressSeparatorRowListRow

Chrome

PortalShellSidebarNavMobileNavTopBarAuthFrameColorSelectorFloatingNav

Tooltip

A short hint on hover and keyboard focus.

Focus the icon
Variations

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

NameTypeDefaultRequiredBindingDescription
textstringNoneYesOne-wayThe tooltip text. It is also the trigger name.
theme'light' | 'dark'lightNoOne-wayTheme scope for the portaled content. Portaled content does not inherit the page scope.

Snippets

NameTypeDefaultRequiredBindingDescription
childrenSnippetNoneNoOne-wayThe 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.

Related

  • Popover
  • Dialog
Previous Popover Next DropdownMenu

On this page

  • Preview
  • Source
  • API reference
  • Props
  • Snippets
  • Forwarded attributes
  • Limits