Veil UI
Components

Tooltip

A short label that appears on hover or focus.

Installation

$ npx veil-ui@latest add tooltip

Usage

import {
  Tooltip,
  TooltipContent,
  TooltipProvider,
  TooltipTrigger,
} from "@/components/ui/tooltip";

<TooltipProvider>
  <Tooltip>
    <TooltipTrigger asChild>
      <Button>Hover</Button>
    </TooltipTrigger>
    <TooltipContent>Helpful text</TooltipContent>
  </Tooltip>
</TooltipProvider>;

Examples

Basic

Sides

With keyboard hint

API reference

PropTypeDefaultDescription
delayDurationnumber700Provider prop. Delay before the tooltip opens.
side"top" | "right" | "bottom" | "left""top"Preferred placement of the content.
sideOffsetnumber6Distance from the trigger in pixels.

Accessibility

  • Tooltips open on hover and keyboard focus, and are linked to the trigger with aria-describedby.
  • Never put interactive content inside a tooltip — it cannot be reached by keyboard.
  • Icon-only triggers still need an aria-label; the tooltip is supplementary.
  • Wrap the app once in TooltipProvider rather than providing it per tooltip.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add tooltip --framework vue or switch the framework in components.json.

<script setup lang="ts">
import {
  TooltipArrow,
  TooltipContent,
  TooltipPortal,
} from "reka-ui";

import { cn } from "@/lib/utils";

const props = withDefaults(
  defineProps<{ class?: string; sideOffset?: number }>(),
  { sideOffset: 6 },
);
</script>

<template>
  <TooltipPortal>
    <TooltipContent
      data-slot="tooltip-content"
      :side-offset="sideOffset"
      :class="
        cn(
          'z-50 w-fit max-w-xs rounded-md bg-foreground px-2.5 py-1.5 text-xs text-background shadow-md',
          'origin-[var(--reka-tooltip-content-transform-origin)]',
          'data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-[state=instant-open]:animate-in data-[state=instant-open]:fade-in-0 data-[state=instant-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 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=bottom]:slide-out-to-top-2 data-[side=top]:slide-out-to-bottom-2 data-[side=left]:slide-out-to-right-2 data-[side=right]:slide-out-to-left-2',
          '[--veil-animation-duration:100ms] [--veil-exit-duration:80ms]',
          props.class,
        )
      "
    >
      <slot />
      <TooltipArrow
        class="z-50 size-2.5 translate-y-[calc(-50%_-_1px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"
      />
    </TooltipContent>
  </TooltipPortal>
</template>

On this page