Tooltips
SSGL supports tooltips on individual GUI components.
Tooltips use Minecraft's native system and appear when the player hovers over a component.
Adding a tooltip
Use .tooltip() after creating a GuiElement.
GuiElement.button("Apply", this::applySettings)
.tooltip("Apply the current settings");
String tooltips
For simple tooltips, provide a regular string.
GuiElement.toggle("Enabled", enabled)
.tooltip("Enable or disable this feature");
Translated tooltips
You can also provide a Minecraft Component.
GuiElement.button(
Component.translatable("mymod.gui.apply"),
this::applySettings
).tooltip(Component.translatable("mymod.gui.apply.tooltip"));
Add the corresponding entry to your language file:
{
"mymod.gui.apply": "Apply",
"mymod.gui.apply.tooltip": "Save your current settings"
}
Supported components
Tooltips work with all individual GuiElement components, including:
- Labels
- Buttons
- Toggles
- State buttons
- Sliders
- Text fields
- Integer fields
- Decimal fields
- Image buttons
For example:
GuiElement.slider("Volume", 0.0, 1.0, volume)
.tooltip("Adjust the volume");
GuiElement.stateButton("Quality", quality)
.tooltip(Component.translatable("mymod.gui.quality.tooltip"));
Combining options
Tooltips can be combined with other element settings.
GuiElement.button("Apply", this::applySettings)
.width(120)
.align(Alignment.CENTER)
.tooltip("Apply all settings");
Empty tooltips
Tooltips are optional. When no tooltip is provided, nothing is displayed.
Empty or blank tooltip text is ignored.
Tooltips are assigned to individual elements, not to layout or scroll-area containers.