Skip to content

feat: add tooltip builtin#11623

Merged
michneaionuc merged 31 commits into
masterfrom
feat/tooltips
May 13, 2026
Merged

feat: add tooltip builtin#11623
michneaionuc merged 31 commits into
masterfrom
feat/tooltips

Conversation

@michneaionuc
Copy link
Copy Markdown
Contributor

This PR introduces built-in tooltip support in Slint (#6446).

You can now attach a ToolTip to an element and get consistent hover behavior (including delay and placement), with proper runtime popup handling and style integration.

Highlights

  • Added built-in ToolTip behavior and lowering pipeline
  • Added tooltip popup kind (Tooltip) alongside existing popup kinds
  • Added validation with clear compiler errors (for example: more than one tooltip on the same parent)
  • Added tests for tooltip behavior and syntax errors
  • Added tooltip docs in builtins.slint
  • Added tooltip examples in Gallery->Controls

How to test

  1. Run the Gallery example and try tooltip interactions
    cargo run -p gallery
    In the UI, open Controls and find the ToolTip section

  2. Regenerate docs locally

cargo run -p slint-doc-generator -- generate-mdx
cargo run -p slint-doc-generator -- screenshots --overwrite docs/astro/src/content
pnpm -C docs/astro dev

Comment thread internal/common/enums.rs Outdated
Comment thread internal/compiler/builtins.slint Outdated
Comment thread internal/compiler/passes/lower_tooltips.rs Outdated
Comment thread internal/compiler/builtins.slint Outdated
Comment thread internal/compiler/langtype.rs
Copy link
Copy Markdown
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One detail about the API is that I wonder how to have custom content, while still having themed tooltip decoration.

Comment thread internal/compiler/passes/windows.rs Outdated
Comment thread internal/compiler/widgets/cosmic/tooltip.slint
Comment thread internal/compiler/builtins.slint Outdated
Comment thread internal/compiler/builtins.slint
Comment thread internal/compiler/builtins.slint
Comment thread internal/compiler/builtins.slint Outdated
Comment thread internal/core/items.rs Outdated
Comment thread internal/compiler/passes/lower_tooltips.rs Outdated
Comment thread internal/compiler/passes/lower_tooltips.rs Outdated
@ogoffart
Copy link
Copy Markdown
Member

ogoffart commented May 5, 2026

I would also like to see a bit more tests for the error case.
What if you have neither test nor element in it, what if you have both, what if you set the x, y property to a Tooltip. Tooltip in places that shouldn't accept tooltip (eg, Timer, Menus, other Tooltip)
At least each error message that you introduce should basically be tested.
Can you put @children in a tooltip?
Can you inherit from Tooltip?
Can you put a Tooltip in a layout?
And all other corner case you can think off.

There should be either syntax test or test that this works.

Comment thread internal/common/enums.rs Outdated
@Murmele
Copy link
Copy Markdown
Contributor

Murmele commented May 7, 2026

@michneaionuc I don't see any tooltip when using qt as backend only for winit

@Murmele
Copy link
Copy Markdown
Contributor

Murmele commented May 7, 2026

I used the tooltip_on_button.slint example
Is it possible to change the distance of the tooltip to the button?

@michneaionuc
Copy link
Copy Markdown
Contributor Author

@michneaionuc I don't see any tooltip when using qt as backend only for winit

I'm gonna have a look at it. Thanks

@michneaionuc
Copy link
Copy Markdown
Contributor Author

I used the tooltip_on_button.slint example Is it possible to change the distance of the tooltip to the button?

Not currently, but good point, I think we should add a configurable tooltip offset property

@michneaionuc michneaionuc merged commit 0282d4f into master May 13, 2026
57 checks passed
@michneaionuc michneaionuc deleted the feat/tooltips branch May 13, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants