Skip to content
Ginga UI
Ginga UI
日本語

Getting started

  • Overview
  • Quick start
  • Theme generation
  • Custom rendering
  • All components

Forms

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

Display

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

Typography

  • Heading
  • Paragraph

Navigation

  • Anchor

Layout

  • Box

Resources

  • Changelog
  • GitHub (opens in a new tab)

Logo: Twemoji (opens in a new tab) (CC-BY 4.0)

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

NameTypeDefaultDescription
disabledbooleanfalseStops the tooltip from opening.

Also accepts the props of React Aria's TooltipTrigger (opens in a new tab).

Tooltip

NameTypeDefaultDescription
childrenReactNode-Content of the tooltip.
showArrowbooleantrueShows an arrow pointing at the trigger. The offset grows by half the arrow size.
placementPlacement"top"Position of the tooltip relative to the trigger.
offsetnumber6Distance from the trigger in pixels.

Also accepts the props of React Aria's Tooltip (opens in a new tab).