본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Tooltip (툴팁)

원문 보기 위키 갱신

Tooltip은 사용자가 어떤 요소를 호버하거나 상호작용할 때 보조 정보를 보여 주는 컴포넌트예요. 표시/숨김 상태와 지연 시간을 조절할 수 있고, 여러 툴팁을 Provider로 묶어 공유 상태로 관리할 수도 있습니다. 모바일에서는 호버 개념이 없어 다른 접근을 권장합니다.

출처: 문서

본문

<script lang="ts">
  import { Tooltip } from "bits-ui";
  import MagicWand from "phosphor-svelte/lib/MagicWand";
</script>
<Tooltip.Provider>
  <Tooltip.Root delayDuration={200}>
    <Tooltip.Trigger
      class="border-border-input bg-background-alt shadow-btn ring-dark ring-offset-background
		hover:bg-muted focus-visible:ring-dark focus-visible:ring-offset-background focus-visible:outline-hidden inline-flex size-10 items-center justify-center rounded-full border focus-visible:ring-2 focus-visible:ring-offset-2"
    >
      <MagicWand class="size-5" />
    </Tooltip.Trigger>
    <Tooltip.Content
      sideOffset={8}
      class="animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--bits-tooltip-content-transform-origin)"
    >
      <div
        class="rounded-input border-dark-10 bg-background shadow-popover outline-hidden z-0 flex items-center justify-center border p-3 text-sm font-medium"
      >
        Make some magic!
      </div>
    </Tooltip.Content>
  </Tooltip.Root>
</Tooltip.Provider>

구조

<script lang="ts">
  import { Tooltip } from "bits-ui";
</script>
<Tooltip.Provider>
  <Tooltip.Root>
    <Tooltip.Trigger />
    <Tooltip.Portal>
      <Tooltip.Content>
        <Tooltip.Arrow />
      </Tooltip.Content>
    </Tooltip.Portal>
  </Tooltip.Root>
</Tooltip.Provider>

Provider 컴포넌트

Tooltip.Provider 컴포넌트는 Tooltip.Root 컴포넌트의 상위에 있어야 해요. Provider는 그 안에서 쓰이는 tooltip 컴포넌트들이 공유할 상태를 제공하는데, Provider에 delayDuration이나 disableHoverableContent 같은 prop 하나만 설정해도 그 안의 모든 tooltip 컴포넌트에 적용할 수 있어요.

<script lang="ts">
  import { Tooltip } from "bits-ui";
</script>
<Tooltip.Provider delayDuration={0} disableHoverableContent={true}>
  <!-- Will have a delayDuration of 0 and disableHoverableContent of true -->
  <Tooltip.Root>
    <Tooltip.Trigger />
    <Tooltip.Portal>
      <Tooltip.Content>
        <Tooltip.Arrow />
      </Tooltip.Content>
    </Tooltip.Portal>
  </Tooltip.Root>
  <!-- Will have a delayDuration of 0 and disableHoverableContent of true -->
  <Tooltip.Root>
    <Tooltip.Trigger />
    <Tooltip.Portal>
      <Tooltip.Content>
        <Tooltip.Arrow />
      </Tooltip.Content>
    </Tooltip.Portal>
  </Tooltip.Root>
</Tooltip.Provider>

또한 같은 Provider 안에서는 한 번에 tooltip 하나만 열려 있도록 보장해요. 루트 레이아웃 콘텐츠를 Provider로 감싸고, 그 자리에 합리적인 기본 props를 설정해 두는 걸 권장합니다.

+layout.svelte

<script lang="ts">
  import { Tooltip } from "bits-ui";
  let { children } = $props();
</script>
<Tooltip.Provider>
  {@render children()}
</Tooltip.Provider>

open 상태 다루기

이번 절에서는 컴포넌트의 open 상태를 어떻게 관리하는지 다뤄요.

양방향 바인딩 (Two-Way Binding)

간단하고 자동적인 상태 동기화를 위해 bind:open을 사용해요:

<script lang="ts">
  import { Tooltip } from "bits-ui";
  let isOpen = $state(false);
</script>
<button onclick={() => (isOpen = true)}>Open Tooltip</button>
<Tooltip.Root bind:open={isOpen}>
  <!-- ... -->
</Tooltip.Root>

완전 제어 (Fully Controlled)

상태의 읽기와 쓰기를 완전히 통제하고 싶다면 Function Binding을 사용해요.

<script lang="ts">
  import { Tooltip } from "bits-ui";
  let myOpen = $state(false);
  function getOpen() {
    return myOpen;
  }
  function setOpen(newOpen: boolean) {
    myOpen = newOpen;
  }
</script>
<Tooltip.Root bind:open={getOpen, setOpen}>
  <!-- ... -->
</Tooltip.Root>

Tether

tether는 Tooltip.Trigger와 Tooltip.Root가 서로 다른 컴포넌트 하위 트리에 있어도 소통할 수 있게 해 주는 공유 연결 객체예요.

tether가 없으면 각 root/trigger 쌍이 지역(local)으로 묶여서, 분리된 레이아웃을 만들기 어려워져요. 예를 들어 한쪽에는 툴바 트리거를, 다른 곳에는 tooltip 콘텐츠를 렌더링해야 하는 상황이 그렇죠. tether는 양쪽에 활성 트리거·열림/닫힘 동작·트리거 페이로드에 대한 공유 상태를 줘서, tooltip 콘텐츠 인스턴스를 중복하지 않고도 싱글턴 스타일의 tooltip 패턴을 만들 수 있게 해요.

tether는 Base UI의 handle 개념에서 영감을 받았어요.

분리된 트리거

동작 컨트롤과 tooltip root가 같은 곳에 있지 않을 때(예: 여러 영역에 툴바 동작이 흩어져 있는 대시보드) 공유 tether를 사용해요:

<script lang="ts">
  import { Tooltip } from "bits-ui";
  const actionsTether = Tooltip.createTether<{
    label: string;
    description: string;
    shortcut: string;
  }>();
</script>
<Tooltip.Trigger
  tether={actionsTether}
  payload={{
    label: "Sync now",
    description:
      "Refreshes every connected source and recalculates all metrics.",
    shortcut: "S",
  }}
>
  Sync now
</Tooltip.Trigger>
<Tooltip.Root tether={actionsTether}>
  {#snippet children({ payload })}
    <Tooltip.Portal>
      <Tooltip.Content>
        <p>{payload?.label}</p>
        <p>{payload?.description}</p>
        <kbd>{payload?.shortcut}</kbd>
      </Tooltip.Content>
    </Tooltip.Portal>
  {/snippet}
</Tooltip.Root>

코드 펼치기

<script lang="ts">
  import { Tooltip } from "bits-ui";
  type ActionTooltipPayload = {
    label: string;
    description: string;
    shortcut: string;
  };
  const actionsTether = Tooltip.createTether<ActionTooltipPayload>();
</script>
<Tooltip.Provider delayDuration={200}>
  <div class="mx-auto grid w-full max-w-[760px] gap-2 sm:grid-cols-2">
    <div
      class="rounded-10px border-border bg-background-alt shadow-mini flex items-center justify-between border p-3"
    >
      <div>
        <p class="text-sm font-semibold">Data sources</p>
        <p class="text-foreground/60 mt-0.5 text-xs">
          Pull live data from connected integrations
        </p>
      </div>
      <Tooltip.Trigger
        tether={actionsTether}
        payload={{
          label: "Sync now",
          description:
            "Refreshes every connected source and recalculates all metrics.",
          shortcut: "S"
        }}
        class="rounded-9px bg-background text-foreground/80 ring-dark ring-offset-background shadow-mini hover:bg-muted focus-visible:ring-dark focus-visible:ring-offset-background focus-visible:outline-hidden active:bg-dark-10 inline-flex h-8 shrink-0 items-center justify-center px-3 text-xs font-medium transition-all focus-visible:ring-2 focus-visible:ring-offset-2 active:scale-[0.98]"
      >
        Sync now
      </Tooltip.Trigger>
    </div>
    <div
      class="rounded-10px border-border bg-background-alt shadow-mini flex items-center justify-between border p-3"
    >
      <div>
        <p class="text-sm font-semibold">Sharing</p>
        <p class="text-foreground/60 mt-0.5 text-xs">
          Share a live view with your team
        </p>
      </div>
      <Tooltip.Trigger
        tether={actionsTether}
        payload={{
          label: "Copy share link",
          description:
            "Creates a read-only link with the current filter and date range.",
          shortcut: "L"
        }}
        class="rounded-9px bg-background text-foreground/80 ring-dark ring-offset-background shadow-mini hover:bg-muted focus-visible:ring-dark focus-visible:ring-offset-background focus-visible:outline-hidden active:bg-dark-10 inline-flex h-8 shrink-0 items-center justify-center px-3 text-xs font-medium transition-all focus-visible:ring-2 focus-visible:ring-offset-2 active:scale-[0.98]"
      >
        Copy link
      </Tooltip.Trigger>
    </div>
    <div
      class="rounded-10px border-border bg-background-alt shadow-mini flex items-center justify-between border p-3 sm:col-span-2"
    >
      <div>
        <p class="text-sm font-semibold">Automation</p>
        <p class="text-foreground/60 mt-0.5 text-xs">
          Send recurring summaries to your team
        </p>
      </div>
      <div class="flex items-center gap-2">
        <Tooltip.Trigger
          tether={actionsTether}
          payload={{
            label: "Schedule digest",
            description:
              "Sends this dashboard summary to your team every Monday at 9:00 AM.",
            shortcut: "D"
          }}
          class="rounded-9px bg-background text-foreground/80 ring-dark ring-offset-background shadow-mini hover:bg-muted focus-visible:ring-dark focus-visible:ring-offset-background focus-visible:outline-hidden active:bg-dark-10 inline-flex h-8 shrink-0 items-center justify-center px-3 text-xs font-medium transition-all focus-visible:ring-2 focus-visible:ring-offset-2 active:scale-[0.98]"
        >
          Schedule digest
        </Tooltip.Trigger>
        <Tooltip.Trigger
          tether={actionsTether}
          payload={{
            label: "Pause digest",
            description:
              "Stops all scheduled sends while keeping existing recipients intact.",
            shortcut: "P"
          }}
          class="rounded-9px bg-background text-foreground/80 ring-dark ring-offset-background shadow-mini hover:bg-muted focus-visible:ring-dark focus-visible:ring-offset-background focus-visible:outline-hidden active:bg-dark-10 inline-flex h-8 shrink-0 items-center justify-center px-3 text-xs font-medium transition-all focus-visible:ring-2 focus-visible:ring-offset-2 active:scale-[0.98]"
        >
          Pause digest
        </Tooltip.Trigger>
      </div>
    </div>
  </div>
  <Tooltip.Root tether={actionsTether}>
    {#snippet children({ payload })}
      <Tooltip.Portal>
        <Tooltip.Content
          sideOffset={8}
          class="data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--bits-tooltip-content-transform-origin)"
        >
          <div
            class="rounded-input border-dark-10 bg-background shadow-popover outline-hidden z-0 w-[280px] border p-3"
          >
            <div class="flex items-center justify-between gap-2">
              <p class="text-sm font-semibold">{payload?.label ?? "Action"}</p>
              <kbd
                class="border-dark-10 text-foreground/65 bg-background-alt rounded-[4px] border px-1.5 py-0.5 font-mono text-[11px]"
              >
                {payload?.shortcut ?? "?"}
              </kbd>
            </div>
            <p class="text-foreground/70 mt-1 text-xs leading-relaxed">
              {payload?.description ??
                "Hover a detached action button to see what it does."}
            </p>
          </div>
        </Tooltip.Content>
      </Tooltip.Portal>
    {/snippet}
  </Tooltip.Root>
</Tooltip.Provider>

페이로드를 가진 싱글턴 Tooltip

하나의 tooltip을 여러 트리거가 재사용할 수 있어요. 활성 트리거의 페이로드는 Tooltip.Root의 스니펫 props에서 가져올 수 있습니다:

<script lang="ts">
  import { Tooltip } from "bits-ui";
  const boardTether = Tooltip.createTether<{
    name: string;
    description: string;
  }>();
</script>
<Tooltip.Root tether={boardTether}>
  {#snippet children({ payload })}
    <Tooltip.Trigger
      tether={boardTether}
      payload={{
        name: "Blocked",
        description: "Waiting on an external dependency.",
      }}
    >
      Blocked
    </Tooltip.Trigger>
    <Tooltip.Trigger
      tether={boardTether}
      payload={{
        name: "Done",
        description: "Ready for release notes and QA sign-off.",
      }}
    >
      Done
    </Tooltip.Trigger>
    <Tooltip.Portal>
      <Tooltip.Content>
        <p>{payload?.name}</p>
        <p>{payload?.description}</p>
      </Tooltip.Content>
    </Tooltip.Portal>
  {/snippet}
</Tooltip.Root>

코드 펼치기

<script lang="ts">
  import { Tooltip } from "bits-ui";
  type ColumnPayload = {
    name: string;
    description: string;
  };
  const boardTether = Tooltip.createTether<ColumnPayload>();
  const columns = [
    {
      id: "backlog",
      label: "Backlog",
      payload: {
        name: "Backlog",
        description:
          "Unstarted ideas and tasks waiting to be scoped and prioritized."
      }
    },
    {
      id: "in-progress",
      label: "In Progress",
      payload: {
        name: "In Progress",
        description: "Active work with an assignee and an expected ship date."
      }
    },
    {
      id: "blocked",
      label: "Blocked",
      payload: {
        name: "Blocked",
        description:
          "Work that cannot move until an external dependency is resolved."
      }
    },
    {
      id: "done",
      label: "Done",
      payload: {
        name: "Done",
        description: "Completed tasks ready for release notes and QA sign-off."
      }
    }
  ];
</script>
<Tooltip.Provider delayDuration={200} skipDelayDuration={600}>
  <Tooltip.Root tether={boardTether}>
    {#snippet children({ payload })}
      <div
        class="rounded-10px border-border bg-background-alt shadow-mini flex flex-wrap items-center gap-1 border p-1"
      >
        {#each columns as column (column.id)}
          <Tooltip.Trigger
            tether={boardTether}
            payload={column.payload}
            class="rounded-9px text-foreground/80 hover:bg-muted data-[state=open]:bg-muted inline-flex h-9 items-center px-3 text-sm font-medium transition-colors"
          >
            {column.label}
          </Tooltip.Trigger>
        {/each}
      </div>
      <Tooltip.Portal>
        <Tooltip.Content
          sideOffset={8}
          class="data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--bits-tooltip-content-transform-origin)"
        >
          <div
            class="rounded-input border-dark-10 bg-background shadow-popover outline-hidden z-0 w-[280px] border p-3"
          >
            <p class="text-sm font-semibold">{payload?.name ?? "Column"}</p>
            <p class="text-foreground/70 mt-1 text-xs leading-relaxed">
              {payload?.description ??
                "Hover a column to see team workflow guidance."}
            </p>
          </div>
        </Tooltip.Content>
      </Tooltip.Portal>
    {/snippet}
  </Tooltip.Root>
</Tooltip.Provider>

제어된 활성 트리거

제어 모드에서는 open과 triggerId를 함께 바인딩해 특정 트리거를 프로그래밍 방식으로 열 수 있어요. 안내형 온보딩 흐름에서 유용합니다:

<script lang="ts">
  import { Tooltip } from "bits-ui";
  const setupTether = Tooltip.createTether<{
    title: string;
    description: string;
  }>();
  let open = $state(false);
  let triggerId = $state<string | null>(null);
</script>
<button
  onclick={() => {
    triggerId = "setup-members";
    open = true;
  }}
>
  Show members tip
</button>
<Tooltip.Root tether={setupTether} bind:open bind:triggerId>
  <!-- ... -->
</Tooltip.Root>

코드 펼치기

<script lang="ts">
  import { Tooltip } from "bits-ui";
  import CursorClick from "phosphor-svelte/lib/CursorClick";
  type StepPayload = {
    title: string;
    description: string;
  };
  const setupTether = Tooltip.createTether<StepPayload>();
  let open = $state(false);
  let triggerId = $state<string | null>(null);
  function openStep(id: string) {
    triggerId = id;
    open = true;
  }
</script>
<Tooltip.Provider delayDuration={200}>
  <div class="flex w-full flex-col items-center gap-3">
    <div
      class="rounded-10px border-border bg-background-alt shadow-mini inline-flex w-fit items-center border p-1"
    >
      <Tooltip.Trigger
        id="setup-project"
        tether={setupTether}
        payload={{
          title: "Create project",
          description:
            "Projects keep workflows, environments, and permissions scoped to one team."
        }}
        class="rounded-9px text-foreground/80 hover:bg-muted inline-flex h-9 items-center px-3 text-sm font-medium"
      >
        Project
      </Tooltip.Trigger>
      <Tooltip.Trigger
        id="setup-members"
        tether={setupTether}
        payload={{
          title: "Invite members",
          description:
            "Add collaborators now so every task gets ownership from day one."
        }}
        class="rounded-9px text-foreground/80 hover:bg-muted inline-flex h-9 items-center px-3 text-sm font-medium"
      >
        Members
      </Tooltip.Trigger>
      <Tooltip.Trigger
        id="setup-deploy"
        tether={setupTether}
        payload={{
          title: "Configure deploy",
          description:
            "Connect a repository and pick a production branch for one-click releases."
        }}
        class="rounded-9px text-foreground/80 hover:bg-muted inline-flex h-9 items-center px-3 text-sm font-medium"
      >
        Deploy
      </Tooltip.Trigger>
    </div>
    <div class="flex w-full max-w-xs items-center gap-3">
      <div class="bg-border h-px flex-1"></div>
      <span
        class="text-foreground/35 text-[10px] font-medium uppercase tracking-widest"
        >open directly</span
      >
      <div class="bg-border h-px flex-1"></div>
    </div>
    <div class="flex flex-wrap items-center justify-center gap-2">
      <button
        type="button"
        class="border-border bg-background-alt shadow-mini hover:bg-muted focus-visible:ring-dark focus-visible:ring-offset-background focus-visible:outline-hidden group inline-flex h-8 items-center gap-1.5 rounded-full border px-4 text-xs font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 active:scale-[0.98]"
        onclick={() => openStep("setup-members")}
      >
        <CursorClick
          class="text-foreground/40 group-hover:text-foreground/60 size-3.5 transition-colors"
        />
        <span
          class="text-foreground/65 group-hover:text-foreground/80 transition-colors"
          >Members</span
        >
      </button>
      <button
        type="button"
        class="border-border bg-background-alt shadow-mini hover:bg-muted focus-visible:ring-dark focus-visible:ring-offset-background focus-visible:outline-hidden group inline-flex h-8 items-center gap-1.5 rounded-full border px-4 text-xs font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 active:scale-[0.98]"
        onclick={() => openStep("setup-deploy")}
      >
        <CursorClick
          class="text-foreground/40 group-hover:text-foreground/60 size-3.5 transition-colors"
        />
        <span
          class="text-foreground/65 group-hover:text-foreground/80 transition-colors"
          >Deploy</span
        >
      </button>
    </div>
  </div>
  <Tooltip.Root tether={setupTether} bind:open bind:triggerId>
    {#snippet children({ payload })}
      <Tooltip.Portal>
        <Tooltip.Content
          sideOffset={8}
          class="animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 origin-(--bits-tooltip-content-transform-origin)"
        >
          <div
            class="rounded-input border-dark-10 bg-background shadow-popover outline-hidden z-0 w-[290px] border p-3"
          >
            <p class="text-sm font-semibold">
              {payload?.title ?? "Setup step"}
            </p>
            <p class="text-foreground/70 mt-1 text-xs leading-relaxed">
              {payload?.description ??
                "Open a step manually to guide first-time users."}
            </p>
          </div>
        </Tooltip.Content>
      </Tooltip.Portal>
    {/snippet}
  </Tooltip.Root>
</Tooltip.Provider>

모바일에서의 Tooltip

tooltip은 모바일 기기에서는 지원되지 않아요. tooltip의 의도는 사용자가 그 도구(대부분 버튼)와 상호작용하기 전에 도구에 대한 "팁"을 주는 것이거든요.

그런데 모바일에는 hover라는 개념이 없어서 이게 불가능해요. tooltip이 달린 버튼을 사용자가 누르거나 터치하면, tooltip을 보기도 전에 그 버튼의 동작이 먼저 실행돼서 tooltip이 무용지물이 되거든요.

동작이 없는 버튼에 tooltip을 쓰고 있다면, 대신 Popover를 고려해 보세요.

이런 결정을 내리게 된 배경을 더 알고 싶다면, 아래 자료들이 도움이 될 거예요:

tooltip은 더 많은 정보를 뜻하는 "i" 아이콘(ⓘ)에 어울리는 역할이 아니에요. tooltip은 소유 요소와 직접 연결되거든요. ⓘ 자체가 상세 정보로 "설명"되는 게 아니라, 그 tool이나 컨트롤이 설명되는 거예요.

MDN ARIA Tooltips

tooltip에는 꼭 필수적이지 않은 내용만 담아야 해요. tooltip 내용을 작성할 때는 "읽히지 않을 수도 있다"고 항상 가정하는 게 가장 좋은 방법이에요.

Tooltips in the time of WCAG 2.1

재사용 가능한 컴포넌트

애플리케이션 전반에서 쓸 수 있는 커스텀 tooltip 컴포넌트를 만들 때는 Tooltip 프리미티브를 활용하는 걸 권장해요.

아래는 애플리케이션 전반에서 재사용할 수 있는 tooltip 컴포넌트를 만드는 예시예요. 물론 이것이 유일한 방법은 아니지만, 프리미티브를 어떻게 조합하는지 감을 잡기 좋습니다.

MyTooltip.svelte

<script lang="ts">
  import { Tooltip } from "bits-ui";
  import { type Snippet } from "svelte";
  type Props = Tooltip.RootProps & {
    trigger: Snippet;
    triggerProps?: Tooltip.TriggerProps;
  };
  let {
    open = $bindable(false),
    children,
    trigger,
    triggerProps = {},
    ...restProps
  }: Props = $props();
</script>
<!--
 Ensure you have a `Tooltip.Provider` component wrapping
 your root layout content
-->
<Tooltip.Root bind:open {...restProps}>
  <Tooltip.Trigger {...triggerProps}>
    {@render trigger()}
  </Tooltip.Trigger>
  <Tooltip.Portal>
    <Tooltip.Content>
      <Tooltip.Arrow />
      {@render children?.()}
    </Tooltip.Content>
  </Tooltip.Portal>
</Tooltip.Root>

그다음에는 이렇게 만든 MyTooltip 컴포넌트를 애플리케이션에서 사용할 수 있어요:

+page.svelte

<script lang="ts">
  import MyTooltip from "$lib/components/MyTooltip.svelte";
  import BoldIcon from "..some-icon-library"; // not real
</script>
<MyTooltip triggerProps={{ onclick: () => alert("changed to bold!") }}>
  {#snippet trigger()}
    <BoldIcon />
  {/snippet}
  Change font to bold
</MyTooltip>

지연 시간 (Delay Duration)

tooltip이 나타나기 전에 사용자가 트리거를 얼마나 오래 호버해야 하는지는 Tooltip.Root나 Tooltip.Provider 컴포넌트의 delayDuration prop으로 조절할 수 있어요.

<Tooltip.Root delayDuration={200}>
  <!-- .... -->
</Tooltip.Root>

지연 건너뛰기 (Skip Delay Duration)

여러 tooltip이 하나의 Tooltip.Provider를 공유할 때, 트리거 사이를 빠르게 오가면 매번 delayDuration 전체를 기다려야 할 수 있어요. skipDelayDuration prop이 이 유예 시간을 조절해요. tooltip을 닫은 뒤 그 시간 안에 어떤 트리거를 다시 들어가면, 기다리지 않고 바로 열립니다.

<Tooltip.Provider delayDuration={600} skipDelayDuration={200}>
  <Tooltip.Root><!-- ... --></Tooltip.Root>
  <Tooltip.Root><!-- ... --></Tooltip.Root>
  <Tooltip.Root><!-- ... --></Tooltip.Root>
</Tooltip.Provider>

툴바나 내비 항목처럼, 첫 번째 tooltip을 열면 그다음부터 tooltip을 훑으려는 의도가 분명한 컨트롤 묶음에 특히 좋아요. 아래 버튼을 호버한 뒤 나머지를 쭉 지나가 보세요. 이후 tooltip들은 지연 없이 열립니다.

코드 펼치기

<script lang="ts">
  import { Tooltip } from "bits-ui";
  import TextB from "phosphor-svelte/lib/TextB";
  import TextItalic from "phosphor-svelte/lib/TextItalic";
  import TextUnderline from "phosphor-svelte/lib/TextUnderline";
  import TextStrikethrough from "phosphor-svelte/lib/TextStrikethrough";
  import Link from "phosphor-svelte/lib/Link";
  import ListBullets from "phosphor-svelte/lib/ListBullets";
  import ListNumbers from "phosphor-svelte/lib/ListNumbers";
  import Code from "phosphor-svelte/lib/Code";
  const tools = [
    { icon: TextB, label: "Bold", shortcut: "⌘B" },
    { icon: TextItalic, label: "Italic", shortcut: "⌘I" },
    { icon: TextUnderline, label: "Underline", shortcut: "⌘U" },
    { icon: TextStrikethrough, label: "Strikethrough", shortcut: "⌘⇧X" },
    { icon: Link, label: "Link", shortcut: "⌘K" },
    { icon: ListBullets, label: "Bullet list", shortcut: "⌘⇧8" },
    { icon: ListNumbers, label: "Numbered list", shortcut: "⌘⇧7" },
    { icon: Code, label: "Code", shortcut: "⌘E" }
  ];
</script>
<Tooltip.Provider delayDuration={600} skipDelayDuration={200}>
  <div
    class="rounded-10px border-border bg-background-alt shadow-mini inline-flex items-center gap-0.5 border p-1"
  >
    {#each tools as tool, i (tool.label)}
      {#if i === 4}
        <div class="bg-border mx-0.5 h-5 w-px shrink-0"></div>
      {/if}
      <Tooltip.Root>
        <Tooltip.Trigger
          class="rounded-9px text-foreground/70 hover:bg-muted hover:text-foreground data-[state=open]:bg-muted data-[state=open]:text-foreground inline-flex size-8 items-center justify-center transition-colors"
        >
          <tool.icon class="size-4" weight="bold" />
        </Tooltip.Trigger>
        <Tooltip.Portal>
          <Tooltip.Content
            sideOffset={8}
            class="data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 origin-(--bits-tooltip-content-transform-origin)"
          >
            <div
              class="rounded-input border-dark-10 bg-background shadow-popover outline-hidden flex items-center gap-2 border px-2.5 py-1.5"
            >
              <span class="text-sm font-medium">{tool.label}</span>
              <kbd
                class="border-dark-10 text-foreground/50 bg-background-alt rounded-[4px] border px-1.5 py-0.5 font-mono text-[11px] leading-none"
              >
                {tool.shortcut}
              </kbd>
            </div>
          </Tooltip.Content>
        </Tooltip.Portal>
      </Tooltip.Root>
    {/each}
  </div>
</Tooltip.Provider>

트리거 클릭 시 닫기

기본적으로 사용자가 오른쪽·가운데 클릭을 포함한 어떤 포인터 버튼으로 트리거를 누르면 tooltip이 닫혀요. 이 동작을 끄고 싶다면 disableCloseOnTriggerClick prop을 true로 설정하면 됩니다.

<Tooltip.Root disableCloseOnTriggerClick>
  <!-- .... -->
</Tooltip.Root>

호버 가능한 콘텐츠

기본적으로 사용자가 콘텐츠 위에 호버하는 동안엔 tooltip이 계속 열려 있어요. 사용자가 콘텐츠 쪽으로 마우스를 옮길 때 닫히게 하고 싶다면 disableHoverableContent prop을 true로 설정하세요.

<Tooltip.Root disableHoverableContent>
  <!-- .... -->
</Tooltip.Root>

키보드가 아닌 포커스

사용자가 키보드가 아닌 방법으로 트리거에 포커스할 때 tooltip이 열리지 않게 하려면 ignoreNonKeyboardFocus prop을 true로 설정해요.

<Tooltip.Root ignoreNonKeyboardFocus>
  <!-- .... -->
</Tooltip.Root>

Svelte 트랜지션

forceMount prop을 child 스니펫과 함께 쓰면 Tooltip.Content 컴포넌트를 강제로 마운트해서, 더 많은 제어가 필요한 Svelte Transitions나 다른 애니메이션 라이브러리를 사용할 수 있어요.

<script lang="ts">
  import { Tooltip } from "bits-ui";
  import { fly, fade } from "svelte/transition";
</script>
<Tooltip.Root>
  <!-- ... other tooltip components -->
  <Tooltip.Content forceMount>
    {#snippet child({ wrapperProps, props, open })}
      {#if open}
        <div {...wrapperProps}>
          <div {...props} transition:fly>
            <!-- ... -->
          </div>
        </div>
      {/if}
    {/snippet}
  </Tooltip.Content>
</Tooltip.Root>

물론 이 문법이 예쁘진 않아서, 앱 전반에 이 방식을 쓰려면 이 로직을 처리하는 재사용 가능한 콘텐츠 컴포넌트를 직접 만드는 걸 권장해요. Bits UI 컴포넌트에서 트랜지션을 쓰는 방법은 Transitions 문서를 참고하세요.

코드 펼치기

<script lang="ts">
  import { Tooltip } from "bits-ui";
  import MagicWand from "phosphor-svelte/lib/MagicWand";
  import { fly } from "svelte/transition";
</script>
<Tooltip.Provider>
  <Tooltip.Root delayDuration={200}>
    <Tooltip.Trigger
      class="border-border-input bg-background-alt shadow-btn ring-dark ring-offset-background
		hover:bg-muted focus-visible:ring-dark focus-visible:ring-offset-background focus-visible:outline-hidden inline-flex size-10 items-center justify-center rounded-full border focus-visible:ring-2 focus-visible:ring-offset-2"
    >
      <MagicWand class="size-5" />
    </Tooltip.Trigger>
    <Tooltip.Content sideOffset={8} forceMount>
      {#snippet child({ wrapperProps, props, open })}
        {#if open}
          <div {...wrapperProps}>
            <div {...props} transition:fly={{ duration: 300 }}>
              <div
                class="rounded-input border-dark-10 bg-background shadow-popover outline-hidden z-0 flex items-center justify-center border p-3 text-sm font-medium"
              >
                Make some magic!
              </div>
            </div>
          </div>
        {/if}
      {/snippet}
    </Tooltip.Content>
  </Tooltip.Root>
</Tooltip.Provider>

같은 강제 마운트 트랜지션 패턴을 싱글턴 트리거와도 조합할 수 있어요:

코드 펼치기

<script lang="ts">
  import { Tooltip } from "bits-ui";
  import { fly } from "svelte/transition";
  type PlanPayload = {
    name: string;
    description: string;
  };
  const planTether = Tooltip.createTether<PlanPayload>();
  const plans = [
    {
      id: "starter",
      label: "Starter",
      payload: {
        name: "Starter plan",
        description:
          "Great for small teams shipping one project with basic analytics."
      }
    },
    {
      id: "growth",
      label: "Growth",
      payload: {
        name: "Growth plan",
        description:
          "Adds feature flags, role permissions, and alert integrations."
      }
    },
    {
      id: "enterprise",
      label: "Enterprise",
      payload: {
        name: "Enterprise plan",
        description:
          "Includes SSO, audit trails, and dedicated support response SLAs."
      }
    }
  ];
</script>
<Tooltip.Provider delayDuration={200}>
  <Tooltip.Root tether={planTether}>
    {#snippet children({ payload })}
      <div
        class="rounded-10px border-border bg-background-alt shadow-mini flex flex-wrap items-center gap-1 border p-1"
      >
        {#each plans as plan (plan.id)}
          <Tooltip.Trigger
            tether={planTether}
            payload={plan.payload}
            class="rounded-9px text-foreground/80 hover:bg-muted data-[state=open]:bg-muted inline-flex h-9 items-center px-3 text-sm font-medium transition-colors"
          >
            {plan.label}
          </Tooltip.Trigger>
        {/each}
      </div>
      <Tooltip.Portal>
        <Tooltip.Content sideOffset={8} forceMount>
          {#snippet child({ wrapperProps, props, open })}
            {#if open}
              <div {...wrapperProps}>
                <div {...props} transition:fly={{ y: 8, duration: 180 }}>
                  <div
                    class="rounded-input border-dark-10 bg-background shadow-popover outline-hidden z-0 w-[300px] border p-3"
                  >
                    <p class="text-sm font-semibold">
                      {payload?.name ?? "Plan details"}
                    </p>
                    <p class="text-foreground/70 mt-1 text-xs leading-relaxed">
                      {payload?.description ??
                        "forceMount keeps one tooltip node mounted so transitions stay smooth while content changes."}
                    </p>
                  </div>
                </div>
              </div>
            {/if}
          {/snippet}
        </Tooltip.Content>
      </Tooltip.Portal>
    {/snippet}
  </Tooltip.Root>
</Tooltip.Provider>

Floating UI 사용하지 않기

Tooltip.Content 컴포넌트를 쓰면 Bits UI는 다른 팝오버 계열 컴포넌트처럼 Floating UI로 트리거 기준 콘텐츠 위치를 잡아요.

이 동작을 원하지 않으면 대신 Tooltip.ContentStatic 컴포넌트를 쓰면 돼요. 이 컴포넌트는 Floating UI를 쓰지 않고 콘텐츠 위치를 전적으로 여러분이 정하게 됩니다.

<Tooltip.Root>
  <Tooltip.Trigger>Hello</Tooltip.Trigger>
  <Tooltip.ContentStatic>
    <!-- ... -->
  </Tooltip.ContentStatic>
</Tooltip.Root>
참고

Tooltip.ContentStatic 컴포넌트를 쓸 때는 Tooltip.Arrow 컴포넌트가 그에 상대적으로 렌더링되지 않아요. Arrow는 Tooltip.Content와 함께 쓰도록 설계되어 있거든요.

커스텀 앵커 (Custom Anchor)

기본적으로 Tooltip.Content는 Tooltip.Trigger 컴포넌트에 앵커링되어 콘텐츠 위치가 정해져요.

콘텐츠를 다른 요소에 앵커링하고 싶다면 Tooltip.Content 컴포넌트의 customAnchor prop에 셀렉터 string이나 HTMLElement를 전달하면 돼요.

<script lang="ts">
  import { Tooltip } from "bits-ui";
  let customAnchor = $state<HTMLElement>(null!);
</script>
<div bind:this={customAnchor}></div>
<Tooltip.Root>
  <Tooltip.Trigger />
  <Tooltip.Content {customAnchor}>
    <!-- ... -->
  </Tooltip.Content>
</Tooltip.Root>

코드 펼치기

<script lang="ts">
  import { Tooltip } from "bits-ui";
  import MagicWand from "phosphor-svelte/lib/MagicWand";
  let customAnchor = $state<HTMLElement | null>(null);
</script>
<div class="flex items-center gap-6">
  <div class="rounded-md border p-3" bind:this={customAnchor}>
    Custom Anchor
  </div>
  <Tooltip.Provider>
    <Tooltip.Root delayDuration={200}>
      <Tooltip.Trigger
        class="border-border-input bg-background-alt shadow-btn ring-dark ring-offset-background
			hover:bg-muted focus-visible:ring-dark focus-visible:ring-offset-background focus-visible:outline-hidden inline-flex size-10 items-center justify-center rounded-full border focus-visible:ring-2 focus-visible:ring-offset-2"
      >
        <MagicWand class="size-5" />
      </Tooltip.Trigger>
      <Tooltip.Content
        sideOffset={8}
        {customAnchor}
        class="animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--bits-tooltip-content-transform-origin)"
      >
        <div
          class="rounded-input border-dark-10 bg-background shadow-popover outline-hidden z-0 flex items-center justify-center border p-3 text-sm font-medium"
        >
          Make some magic!
        </div>
      </Tooltip.Content>
    </Tooltip.Root>
  </Tooltip.Provider>
</div>

API 참조

Tooltip.Provider

하위 트리에 있는 tooltip들의 공유 상태와 로직을 담당하는 Provider 컴포넌트예요.

Property Type Description Details
delayDuration number The amount of time in milliseconds to delay opening the tooltip when hovering over the trigger.Default: 700
disableHoverableContent boolean Whether or not to disable the hoverable content. This is useful when the content contains interactive elements.Default: false
disabled boolean Whether or not the tooltip is disabled.Default: false
disableCloseOnTriggerClick boolean Whether or not to prevent the tooltip from closing when the trigger is pressed with any pointer button.Default: false
skipDelayDuration number The amount of time in milliseconds to delay opening the tooltip when the user has used their mouse to hover over the trigger.Default: 300
ignoreNonKeyboardFocus boolean Whether or not to ignore the tooltip when the focus is not on the trigger. This is useful when the content contains interactive elements.Default: false
children Snippet The children content to render.Default:  —— undefined

Tooltip.Root

tooltip의 각 부분을 담고 있는 루트 컴포넌트예요. Tooltip.Provider 컴포넌트의 하위에 있어야 하고, 싱글턴 모드에서는 루트 children 스니펫 props에 open, triggerId, payload가 포함돼요.

Property Type Description Details
open $bindable boolean The open state of the component.Default: false
onOpenChange function - (open: boolean) => void A callback function called when the open state changes.Default:  —— undefined
onOpenChangeComplete function - (open: boolean) => void A callback function called after the open state changes and all animations have completed.Default:  —— undefined
disabled boolean Whether or not the tooltip is disabled.Default: false
delayDuration number The amount of time in milliseconds to delay opening the tooltip when hovering over the trigger.Default: 700
disableHoverableContent boolean Whether or not to disable the hoverable content. This is useful when the content contains interactive elements.Default: false
disableCloseOnTriggerClick boolean Whether or not to prevent the tooltip from closing when the trigger is pressed with any pointer button.Default: false
ignoreNonKeyboardFocus boolean Whether or not to ignore the tooltip when the focus is not on the trigger. This is useful when the content contains interactive elements.Default: false
triggerId $bindable string | null The active trigger id for controlled singleton tooltips. Useful with bind:triggerId and programmatic open behavior.Default: null
tether TooltipTether<any> A shared tether object created by Tooltip.createTether() used to connect detached triggers and infer root snippet payload types.Default:  —— undefined
children Snippet The children content to render.Default:  —— undefined

Tooltip.Trigger

호버나 포커스로 tooltip을 열고 닫게 해 주는 컴포넌트예요.

Property Type Description Details
disabled boolean Whether or not the tooltip trigger is disabled.Default: false
payload Payload Payload associated with this trigger. The active payload is available from the Tooltip.Root children snippet props.Default:  —— undefined
tether TooltipTether<any> A shared tether object created by Tooltip.createTether() used to connect detached triggers and infer root snippet payload types.Default:  —— undefined
ref $bindable HTMLButtonElement The underlying DOM element being rendered. You can bind to this to get a reference to the element.Default: null
children Snippet The children content to render.Default:  —— undefined
child Snippet - type SnippetProps = { props: Record<string, unknown>; }; Use render delegation to render your own element. See Child Snippet docs for more information.Default:  —— undefined
Data Attribute Value Description Details
data-state enum - 'delayed-open' | 'instant-open' | 'closed' Whether/how the tooltip is open or closed. When open, if there is a delay, the value will be 'delayed-open', otherwise it will be 'instant-open'. When closed, the value will be 'closed'.
data-tooltip-trigger '' Present on the tooltip trigger element.

Tooltip.Content

tooltip이 열렸을 때 표시되는 tooltip의 내용이에요.

Property Type Description Details
side enum - 'top' | 'bottom' | 'left' | 'right' The preferred side of the anchor to render the floating element against when open. Will be reversed when collisions occur.Default: 'bottom'
sideOffset number The distance in pixels from the anchor to the floating element.Default: 0
align enum - 'start' | 'center' | 'end' The preferred alignment of the anchor to render the floating element against when open. This may change when collisions occur.Default: 'start'
alignOffset number The distance in pixels from the anchor to the floating element.Default: 0
arrowPadding number The amount in pixels of virtual padding around the viewport edges to check for overflow which will cause a collision.Default: 0
avoidCollisions boolean When true, overrides the side and align options to prevent collisions with the boundary edges.Default: true
collisionBoundary union - Element | null A boundary element or array of elements to check for collisions against.Default:  —— undefined
collisionPadding union - number | Partial<Record<Side, number>> The amount in pixels of virtual padding around the viewport edges to check for overflow which will cause a collision.Default: 0
sticky enum - 'partial' | 'always' The sticky behavior on the align axis. 'partial' will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst 'always' will keep the content in the boundary regardless.Default: 'partial'
hideWhenDetached boolean When true, hides the content when it is detached from the DOM. This is useful for when you want to hide the content when the user scrolls away.Default: true
updatePositionStrategy enum - 'optimized' | 'always' The strategy to use when updating the position of the content. When 'optimized' the content will only be repositioned when the trigger is in the viewport. When 'always' the content will be repositioned whenever the position changes.Default: 'optimized'
strategy enum - 'fixed' | 'absolute' The positioning strategy to use for the floating element. When 'fixed' the element will be positioned relative to the viewport. When 'absolute' the element will be positioned relative to the nearest positioned ancestor.Default: 'fixed'
preventScroll boolean When true, prevents the body from scrolling when the content is open. This is useful when you want to use the content as a modal.Default: true
customAnchor union - string | HTMLElement | Measurable | null Use an element other than the trigger to anchor the content to. If provided, the content will be anchored to the provided element instead of the trigger.Default: null
onInteractOutside function - (event: PointerEvent) => void Callback fired when an outside interaction event occurs, which is a pointerdown event. You can call event.preventDefault() to prevent the default behavior of handling the outside interaction.Default:  —— undefined
onFocusOutside function - (event: FocusEvent) => void Callback fired when focus leaves the dismissible layer. You can call event.preventDefault() to prevent the default behavior on focus leaving the layer.Default:  —— undefined
interactOutsideBehavior enum - 'close' | 'ignore' | 'defer-otherwise-close' | 'defer-otherwise-ignore' The behavior to use when an interaction occurs outside of the floating content. 'close' will close the content immediately. 'ignore' will prevent the content from closing. 'defer-otherwise-close' will defer to the parent element if it exists, otherwise it will close the content. 'defer-otherwise-ignore' will defer to the parent element if it exists, otherwise it will ignore the interaction.Default: 'close'
onEscapeKeydown function - (event: KeyboardEvent) => void Callback fired when an escape keydown event occurs in the floating content. You can call event.preventDefault() to prevent the default behavior of handling the escape keydown event.Default:  —— undefined
escapeKeydownBehavior enum - 'close' | 'ignore' | 'defer-otherwise-close' | 'defer-otherwise-ignore' The behavior to use when an escape keydown event occurs in the floating content. 'close' will close the content immediately. 'ignore' will prevent the content from closing. 'defer-otherwise-close' will defer to the parent element if it exists, otherwise it will close the content. 'defer-otherwise-ignore' will defer to the parent element if it exists, otherwise it will ignore the interaction.Default: 'close'
forceMount boolean Whether or not to forcefully mount the content. This is useful if you want to use Svelte transitions or another animation library for the content.Default: false
dir enum - 'ltr' | 'rtl' The reading direction of the app.Default: 'ltr'
ref $bindable HTMLDivElement The underlying DOM element being rendered. You can bind to this to get a reference to the element.Default: null
children Snippet The children content to render.Default:  —— undefined
child Snippet - type ChildSnippetProps = { /** * Props for the positioning wrapper * Do not style this element - * styling should be applied to the content element */ wrapperProps: Record<string, unknown>; /** * Props for your content element * Apply your custom styles here */ props: Record<string, unknown>; /** * Content visibility state * Use this for conditional rendering with * Svelte transitions */ open: boolean; }; Use render delegation to render your own element. See Child Snippet docs for more information.Default:  —— undefined
Data Attribute Value Description Details
data-state enum - 'delayed-open' | 'instant-open' | 'closed' Whether/how the tooltip is open or closed. When open, if there is a delay, the value will be 'delayed-open', otherwise it will be 'instant-open'. When closed, the value will be 'closed'.
data-starting-style '' Present during the initial open frame. Use this to define the starting styles for CSS transitions.
data-ending-style '' Present while closing before unmount. Use this to define the ending styles for CSS transitions.
data-tooltip-content '' Present on the tooltip content element.
CSS Variable Description Details
--bits-tooltip-content-transform-origin The transform origin of the content element.
--bits-tooltip-content-available-width The available width of the content element.
--bits-tooltip-content-available-height The available height of the content element.
--bits-tooltip-anchor-width The width of the anchor element.
--bits-tooltip-anchor-height The height of the anchor element.

Tooltip.ContentStatic

tooltip이 열렸을 때 표시되는 내용이에요. (Static/Floating UI를 쓰지 않는 버전)

Property Type Description Details
onInteractOutside function - (event: PointerEvent) => void Callback fired when an outside interaction event occurs, which is a pointerdown event. You can call event.preventDefault() to prevent the default behavior of handling the outside interaction.Default:  —— undefined
onFocusOutside function - (event: FocusEvent) => void Callback fired when focus leaves the dismissible layer. You can call event.preventDefault() to prevent the default behavior on focus leaving the layer.Default:  —— undefined
interactOutsideBehavior enum - 'close' | 'ignore' | 'defer-otherwise-close' | 'defer-otherwise-ignore' The behavior to use when an interaction occurs outside of the floating content. 'close' will close the content immediately. 'ignore' will prevent the content from closing. 'defer-otherwise-close' will defer to the parent element if it exists, otherwise it will close the content. 'defer-otherwise-ignore' will defer to the parent element if it exists, otherwise it will ignore the interaction.Default: 'close'
onEscapeKeydown function - (event: KeyboardEvent) => void Callback fired when an escape keydown event occurs in the floating content. You can call event.preventDefault() to prevent the default behavior of handling the escape keydown event.Default:  —— undefined
escapeKeydownBehavior enum - 'close' | 'ignore' | 'defer-otherwise-close' | 'defer-otherwise-ignore' The behavior to use when an escape keydown event occurs in the floating content. 'close' will close the content immediately. 'ignore' will prevent the content from closing. 'defer-otherwise-close' will defer to the parent element if it exists, otherwise it will close the content. 'defer-otherwise-ignore' will defer to the parent element if it exists, otherwise it will ignore the interaction.Default: 'close'
forceMount boolean Whether or not to forcefully mount the content. This is useful if you want to use Svelte transitions or another animation library for the content.Default: false
dir enum - 'ltr' | 'rtl' The reading direction of the app.Default: 'ltr'
ref $bindable HTMLDivElement The underlying DOM element being rendered. You can bind to this to get a reference to the element.Default: null
children Snippet The children content to render.Default:  —— undefined
child Snippet - type ChildSnippetProps = { open: boolean; props: Record<string, unknown>; }; Use render delegation to render your own element. See Child Snippet docs for more information.Default:  —— undefined
Data Attribute Value Description Details
data-state enum - 'delayed-open' | 'instant-open' | 'closed' Whether/how the tooltip is open or closed. When open, if there is a delay, the value will be 'delayed-open', otherwise it will be 'instant-open'. When closed, the value will be 'closed'.
data-starting-style '' Present during the initial open frame. Use this to define the starting styles for CSS transitions.
data-ending-style '' Present while closing before unmount. Use this to define the ending styles for CSS transitions.
data-tooltip-content '' Present on the tooltip content element.

Tooltip.Arrow

tooltip이 열렸을 때 트리거를 가리키는 선택적인 화살표 요소예요.

Property Type Description Details
width number The width of the arrow in pixels.Default: 8
height number The height of the arrow in pixels.Default: 8
ref $bindable HTMLDivElement The underlying DOM element being rendered. You can bind to this to get a reference to the element.Default: null
children Snippet The children content to render.Default:  —— undefined
child Snippet - type SnippetProps = { props: Record<string, unknown>; }; Use render delegation to render your own element. See Child Snippet docs for more information.Default:  —— undefined
Data Attribute Value Description Details
data-arrow '' Present on the arrow element.
data-tooltip-arrow '' Present on the arrow element.
data-side enum - 'top' | 'right' | 'bottom' | 'left' The side of the tooltip that the arrow is on.

Tooltip.Portal

사용하면 tooltip 내용이 열릴 때 body나 커스텀 to 요소로 렌더링돼요.

Property Type Description Details
to union - Element | string Where to render the content when it is open. Defaults to the body.Default: document.body
disabled boolean Whether the portal is disabled or not. When disabled, the content will be rendered in its original DOM location.Default: false
children Snippet The children content to render.Default:  —— undefined

더 알아보기 (Learn more)

Tooltip은 보조 정보를 다루는 컴포넌트라, 팝오버 계열의 Popover와 함께 이해하면 좋아요. 여러 tooltip을 Provider로 묶어 공유 상태를 만들거나 Floating UI를 끄는 옵션까지, 사용할 곳의 맥락에 맞춰 선택해 보세요.