Tooltip

A short hint shown on hover or keyboard focus.

Status: stable. Category: Overlays.

import { Tooltip } from '@glyphui/ui'

Exports: Tooltip, tooltipStyles.

Notes

  • The child must be focusable (a button or link) so keyboard users see the hint too.
  • Never put essential information only in a tooltip; touch screens cannot hover.

Tooltip props

PropTypeDefaultDescription
content (required)ReactNode
asChildboolean
delayDurationnumber
disabledbooleanSkip the tooltip entirely, e.g. when the label is already visible.

Example: On an icon button

import { IconButton, Tooltip } from '@glyphui/ui'
import { Bell, Settings2 } from 'lucide-react'

export default function Example() {
  return (
    <div className="flex gap-2">
      <Tooltip content="Notifications">
        <IconButton icon={<Bell />} aria-label="Notifications" variant="outline" />
      </Tooltip>
      <Tooltip content="Settings">
        <IconButton icon={<Settings2 />} aria-label="Settings" variant="outline" />
      </Tooltip>
    </div>
  )
}

Example: Placement

import { Button, Tooltip } from '@glyphui/ui'

export default function Example() {
  return (
    <div className="flex flex-wrap gap-2">
      {(['top', 'right', 'bottom', 'left'] as const).map((side) => (
        <Tooltip key={side} content={`Shown on the ${side}`} side={side}>
          <Button variant="outline" size="sm">
            {side}
          </Button>
        </Tooltip>
      ))}
    </div>
  )
}

Live page: https://glyphui.xyz/components/tooltip