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
| Prop | Description | Required | Value |
|---|---|---|---|
| className | custom styling | optional | SCSS or Tailwind |
| children | component(s) to wrap within tooltip | optional | component(s) |
| sideOffset | offset of the tooltip from the trigger | optional | integer (default: 4) |
Notes
- The
Tooltipcomponent usesTooltipPrimitivefrom@radix-ui/react-tooltipfor tooltip functionality. - Pass
classNameandsideOffsettoTooltipContentto style and position the popup. - The
childrenprop is required and should include the trigger and content for the tooltip. - The
sideOffsetprop specifies the offset of the tooltip from the trigger and defaults to 4. - For more details, refer to the Shadcn Tooltip documentation.