Tooltip
A short label shown on hover or focus. Useful for describing icon-only buttons.
View in Storybook (opens in a new tab)
Installation
import { Tooltip } from "@ginga-ui/core";Basic usage
Put the trigger element and a Tooltip inside TooltipTrigger. It appears on hover or keyboard focus.
tooltip.tsx
import { Button, Tooltip, TooltipTrigger } from "@ginga-ui/core";
import { Settings } from "lucide-react";
export function BasicExample() {
return (
<TooltipTrigger>
<Button variant="ghost" aria-label="Settings">
<Settings />
</Button>
<Tooltip>Settings</Tooltip>
</TooltipTrigger>
);
}Placement
Use placement to set the position. The default is top.
tooltip.tsx
tooltip.module.css
import { Button, Tooltip, TooltipTrigger } from "@ginga-ui/core";
import styles from "./tooltip.module.css";
export function PlacementsExample() {
return (
<div className={styles.placementList}>
{(["top", "bottom", "left", "right"] as const).map((placement) => (
<TooltipTrigger key={placement}>
<Button variant="outline">{placement}</Button>
<Tooltip placement={placement}>Appears on the {placement}</Tooltip>
</TooltipTrigger>
))}
</div>
);
}Without arrow
Pass false to showArrow to hide the arrow.
tooltip.tsx
import { Button, Tooltip, TooltipTrigger } from "@ginga-ui/core";
export function WithoutArrowExample() {
return (
<TooltipTrigger>
<Button variant="light">No arrow</Button>
<Tooltip showArrow={false}>A tooltip without an arrow</Tooltip>
</TooltipTrigger>
);
}Props
TooltipTrigger
| Name | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Stops the tooltip from opening. |
Also accepts the props of React Aria's TooltipTrigger (opens in a new tab).
Tooltip
| Name | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | Content of the tooltip. |
showArrow | boolean | true | Shows an arrow pointing at the trigger. The offset grows by half the arrow size. |
placement | Placement | "top" | Position of the tooltip relative to the trigger. |
offset | number | 6 | Distance from the trigger in pixels. |
Also accepts the props of React Aria's Tooltip (opens in a new tab).