Incubator Tooltip: Tooltip is a component that can be used in conjunction with any component to display contextual information.
When the attached component is hovered, the tooltip displays the contextual information.
How is it used?
A simple use of the tooltip component would be the following.
Button button = new Button("Click me");
Tooltip tooltip = new Tooltip();
tooltip.attachToComponent(button);
tooltip.setPosition(TooltipPosition.RIGHT);
tooltip.setAlignment(TooltipAlignment.LEFT);
tooltip.add(new H5("Hello"));
tooltip.add(new Paragraph("This is an example of how to use it"));
It is possible to open and close the tooltip manually:
Button open = new Button("Open tooltip", event -> {
tooltip.open();
});
Button close = new Button("Close tooltip", event -> {
tooltip.close();
});
button.addClickListener(event -> {
tooltip.setEnabled(!tooltip.isEnabled());
});