UI Logo

UI

Tooltip

A tooltip component for displaying additional information on hover or focus.

'use client'

import { Tooltip, TooltipTrigger, TooltipContent } from '@radix-ui/react-tooltip'

export default function TooltipDemo() {
  return (
    <div className='flex flex-col items-center justify-center gap-5 lg:flex-row'>
      <Tooltip>
        <TooltipTrigger asChild>
          <button>Hover over me</button>
        </TooltipTrigger>
        <TooltipContent side="top">
          <div className="tooltip-content">This is a tooltip</div>
        </TooltipContent>
      </Tooltip>
    </div>
  )
}

Installation

Copy and paste the following code into your project.

Update the import paths to match your project setup.

Anatomy

Import all parts and piece them together.

import Tooltip from "@/components/ui/tooltip"
<Tooltip content="Sample tooltip" position="top">Hover me</Tooltip>

Props

Content

Content

  • string

Position

Position

  • top
  • bottom
  • left
  • right