Skip to content
Gravity Logo / Docs Gravity home
Browse documentation
Documentation/Gravity Web

Tooltip

The Tooltip component provides a popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.

Usage

import { Tooltip, TooltipTrigger, TooltipContent } from 'components/lib';

function MyComponent({ ...props }){
  return (
      <Tooltip>
      
        <TooltipTrigger asChild>
          <button>Hover me</button>
        </TooltipTrigger>
        
        <TooltipContent>
          Tooltip content goes here
        </TooltipContent>
        
      </Tooltip>
  );
}

Props

PropDescriptionRequiredValue
classNamecustom stylingoptionalSCSS or Tailwind
childrencomponent(s) to wrap within tooltipoptionalcomponent(s)
sideOffsetoffset of the tooltip from the triggeroptionalinteger (default: 4)

Notes

  • The Tooltip component uses TooltipPrimitive from @radix-ui/react-tooltip for tooltip functionality.
  • Pass className and sideOffset to TooltipContent to style and position the popup.
  • The children prop is required and should include the trigger and content for the tooltip.
  • The sideOffset prop specifies the offset of the tooltip from the trigger and defaults to 4.
  • For more details, refer to the Shadcn Tooltip documentation.