Skip to content

Tooltip: hints

Build hints with Tooltip. This page includes a runnable example, all props, and behavior constraints.

Complete example

Complete environment setup first. Copy this complete main.go and run go run ..

go
package main

import (
	"github.com/dxui-org/dxui"
	"log"
	"time"
)

func main() {

	app := dxui.NewApp(dxui.AppOptions{
		Title:      "Tooltip",
		Width:      640,
		Height:     480,
		Background: dxui.RGBA(248, 250, 252, 255),
	})
	if err := app.Run(func() dxui.View {
		return dxui.Box(
			dxui.BoxProps{
				Gap: 16,
				Style: dxui.Style{
					Padding: dxui.Padding(24),
				},
			},
			dxui.Tooltip(
				dxui.TooltipProps{
					Placement: dxui.OverlayTop,
					Delay:     700 * time.Millisecond,
				},
				dxui.TextButton(dxui.ButtonProps{}, "Hover or Tab here"),
				dxui.Label("A helpful hint"),
			),
		)
	}); err != nil {

		log.Fatal(err)
	}
}

Parameters and API

go
func Tooltip(props TooltipProps, anchor, content View) View
FieldTypePurpose, defaults, and constraints
KeystringStable unique identity within one parent; empty by default. Use business IDs in dynamic lists, not changing indices.
StyleStyleLocal layout, paint, and text styling; zero uses intrinsic sizes and theme defaults.
TokenComponentTokenComponent theme entry; empty selects its default.
StatesStateStylesPaint patches for actual interaction states; cannot fabricate state or change layout.
PointerPointerBehaviorDefaults to PointerAuto; PointerNone excludes the entire subtree from pointer participation, unlike Disabled.
PlacementOverlayPlacementDefaults to OverlayBottomStart; eight placement/alignment values are available.
OffsetMetricValueOptional literal/token spacing for the overlay.
Delaytime.Duration0 selects the default 500ms delay; negative values are invalid.
DisabledboolDefaults to false; true removes focus and cancels interaction on interactive components.

Behavior and limitations

Accepts anchor and content. Hover or keyboard focus starts Delay; leaving and losing focus closes it. Delay=0 means 500ms, not immediate display. Disabled suppresses the hint. Content is noninteractive, takes no focus, and does not block pointers; use Popover for interactive content. Driven by events/deadlines, with no application timer loop.

All components share identity, style, and pointer rules. See full declarations for referenced enums, structs, and comments. Running examples explains build verification.