Skip to content

U0019 ui-hover-text

Rule: An icon-only or glyph button says what it does in a tooltip.

Code U0019 (stable, never reused)
Id ui-hover-text
Category ui
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded off
ui warn an icon-only button with no tooltip has no words at all; a candidate, since a short label may be a real word or get help another way
egui warn an icon-only button with no tooltip has no words at all; a candidate, since a short label may be a real word or get help another way
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
button-calls list of strings [] calls that make a button from a label
hover-calls list of strings [] calls that attach a tooltip
toolkits list of strings ["egui", "eframe", "iced", "slint", "gtk4", "relm4", "dioxus", "leptos", "yew", "floem", "xilem", "makepad-widgets"] UI toolkits: a crate that depends on one directly is a UI crate, unless the crate map says ui = false

Why

A button whose label is a glyph or an icon carries no words a screen reader or a person scanning the toolbar can read; a tooltip is the only place left to say what it does. The check is a candidate: a short label can be a real word in another script, and a project may have its own way of attaching help text that the lint does not see.

The lint reports a call of button-calls whose label, trimmed, holds no letter or digit (an icon) or is one of egui-status-glyph's glyphs (a status glyph), when no call of hover-calls wraps it.

ui.button("🗑");                       // reported: no tooltip says what it does
ui.button("🗑").on_hover_text("Delete"); // passes
ui.button("Delete");                    // passes: the label is words, not an icon

How to fix

Attach a tooltip (one of hover-calls) naming the action.

Configure

[lints.ui-hover-text]
level = "deny"
button-calls = []
hover-calls = []
toolkits = ["egui", "eframe", "iced", "slint", "gtk4", "relm4", "dioxus", "leptos", "yew", "floem", "xilem", "makepad-widgets"]
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(ui-hover-text) <reason> (waivers); the code works there too, as in [lints.U0019].