tooltip

package
v1.0.31-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tooltip

type Tooltip struct {
	// Contextual gives it a context menu (Context).
	elements.Contextual
	// contains filtered or unexported fields
}

Tooltip is a stateful tooltip wrapping trigger: hovering trigger with a mouse, or long-pressing it on a touch screen, shows content in a small panel anchored just below it, rendered above everything else via elements.RegisterPortal. After a long-press the tooltip stays for a moment once the finger lifts. Create it once with New and lay it out every frame in trigger's place.

func New

func New(trigger elements.Element, content string, st ...styles.Styles) *Tooltip

New wraps trigger with a tooltip showing content on hover or long-press. The styles argument is optional: Background and Color style the panel, FontSize its text.

func (*Tooltip) Hovered

func (t *Tooltip) Hovered() bool

Hovered reports whether a mouse was over the trigger on the last frame.

func (*Tooltip) Layout

func (t *Tooltip) Layout(gtx layout.Context) layout.Dimensions

Layout lays out the trigger and, while hovered or long-pressed, queues the tooltip panel as a portal beside it (see Placement).

func (*Tooltip) Placement

func (t *Tooltip) Placement(p elements.Placement) *Tooltip

Placement chooses the side of the trigger the tooltip shows on: elements.PlaceAuto (the default) shows it below, or above when it wouldn't fit below; PlaceBelow and PlaceAbove keep it on one side.

func (*Tooltip) SetContent

func (t *Tooltip) SetContent(content string)

SetContent replaces the tooltip text.

func (*Tooltip) Visible

func (t *Tooltip) Visible() bool

Visible reports whether the tooltip was showing on the last frame, from hover or a long-press.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL