YaVendio Registry
Components

YA Tooltip

A tooltip component with native Radix positioning for contextual information

The YaTooltip component displays contextual information when users hover over or focus on an element. It uses Radix UI's native positioning and arrow for robust placement that automatically adjusts to viewport constraints. Built on top of Radix UI's Tooltip primitive for full accessibility support.

Quick Start

pnpm dlx shadcn@latest add @yavendio/ya-tooltip
npx shadcn@latest add @yavendio/ya-tooltip
yarn dlx shadcn@latest add @yavendio/ya-tooltip
import { YaTooltip, YaTooltipProvider } from '@/components/ui/ya-tooltip'

export default function Example() {
  return (
    <YaTooltipProvider>
      <YaTooltip content="Add to library">
        <button>Hover me</button>
      </YaTooltip>
    </YaTooltipProvider>
  )
}

Wrap your application or component tree with YaTooltipProvider to enable tooltips.

Basic Usage

Positions

YaTooltip supports 4 positions: top, bottom, left, and right. The tooltip automatically adjusts when near viewport edges.

<YaTooltip content="Top position" side="top">
  <button>Top</button>
</YaTooltip>

<YaTooltip content="Bottom position" side="bottom">
  <button>Bottom</button>
</YaTooltip>

<YaTooltip content="Left position" side="left">
  <button>Left</button>
</YaTooltip>

<YaTooltip content="Right position" side="right">
  <button>Right</button>
</YaTooltip>
SideDescription
topTooltip appears above the trigger (default)
bottomTooltip appears below the trigger
leftTooltip appears to the left of the trigger
rightTooltip appears to the right of the trigger

Hide Arrow

Use showArrow={false} to hide the arrow indicator.

<YaTooltip content="No arrow indicator" showArrow={false}>
  <button>No Arrow</button>
</YaTooltip>

Delay Duration

Control how quickly the tooltip appears:

// Quick appearance (100ms)
<YaTooltip content="Quick tooltip" delayDuration={100}>
  <button>Quick</button>
</YaTooltip>

// Delayed appearance (500ms)
<YaTooltip content="Delayed tooltip" delayDuration={500}>
  <button>Delayed</button>
</YaTooltip>

With Icons

import { Info, HelpCircle, Settings, Bell } from 'lucide-react'

<YaTooltip content="More information about this feature">
  <button className="p-2">
    <Info className="w-4 h-4" />
  </button>
</YaTooltip>

<YaTooltip content="Need help? Click for documentation">
  <button className="p-2">
    <HelpCircle className="w-4 h-4" />
  </button>
</YaTooltip>

With YaButton

import { YaButton } from '@/components/ui/ya-button'

<YaTooltip content="Save your changes" side="top">
  <YaButton variant="primary">Save</YaButton>
</YaTooltip>

<YaTooltip content="Discard all changes" side="top">
  <YaButton variant="secondary">Cancel</YaButton>
</YaTooltip>

Controlled Mode

const [open, setOpen] = React.useState(false)

<YaTooltip
  content="This tooltip is controlled"
  open={open}
  onOpenChange={setOpen}
>
  <button>Controlled Tooltip</button>
</YaTooltip>

Provider Configuration

Configure default settings for all tooltips using YaTooltipProvider:

<YaTooltipProvider 
  delayDuration={300}
  skipDelayDuration={500}
  disableHoverableContent={false}
>
  {/* All tooltips inside will use these defaults */}
  <YaTooltip content="Configured tooltip">
    <button>Hover</button>
  </YaTooltip>
</YaTooltipProvider>

Collision Detection

YaTooltip automatically adjusts its position when the tooltip would overflow the viewport. This is handled natively by Radix UI's positioning engine:

  • When near the top edge, it flips to the bottom
  • When near the left edge, it shifts right
  • The arrow position updates automatically to stay aligned with the trigger

Dark Mode

YaTooltip automatically adapts to dark mode:

ModeBackgroundText
LightDark (--ya-stone-900)White
DarkLight (--ya-stone-50)Black

Standalone Content

Use YaTooltipContent for standalone tooltip-styled content:

Default Content

With Arrow

import { YaTooltipContent } from '@/components/ui/ya-tooltip'

<YaTooltipContent>Default Content</YaTooltipContent>
<YaTooltipContent showArrow>With Arrow</YaTooltipContent>

Props

YaTooltipProvider Props

PropTypeDefaultDescription
delayDurationnumber200Default delay before tooltips appear (ms)
skipDelayDurationnumber300How long to skip delay after showing a tooltip
disableHoverableContentbooleanfalsePrevents hovering over the tooltip content

YaTooltip Props

PropTypeDefaultDescription
contentReactNode-Required. Content to display inside the tooltip
side'top' | 'bottom' | 'left' | 'right''top'Side of the trigger to place the tooltip
showArrowbooleantrueWhether to show the arrow indicator
delayDurationnumber-Override provider's delay for this tooltip
openboolean-Controlled open state
defaultOpenboolean-Default open state (uncontrolled)
onOpenChange(open: boolean) => void-Callback when open state changes
sideOffsetnumber4Offset distance from trigger element
classNamestring-Additional CSS classes

YaTooltipContent Props

PropTypeDefaultDescription
showArrowbooleanfalseWhether to show the arrow indicator
classNamestring-Additional CSS classes

Accessibility

Best Practices

DoDon't
Keep content concise (1-2 lines)Long paragraphs or complex content
Use for non-essential informationCritical information only in tooltips
Quick delay for icon buttons (100-200ms)Same delay for all tooltip types
Provide touch alternativesRely solely on hover interactions
Let Radix handle collision detectionManually position tooltips

TypeScript

import type { TooltipSide, YaTooltipProps } from '@/components/ui/ya-tooltip'

interface MyComponentProps {
  tooltipSide?: TooltipSide
}

Migration from Previous Version

If you were using the previous arrow prop with 9 positions, here's how to migrate:

Previous arrowNew side
top-leftside="top"
top-centerside="top"
top-rightside="top"
bottom-leftside="bottom"
bottom-centerside="bottom"
bottom-rightside="bottom"
leftside="left"
rightside="right"
noneshowArrow={false}

On this page