Label
Label shows read-only text on its own row - an explanation, a heading or a value - and wraps long text onto several lines.
Read-only text on its own row: an explanation, a heading, or a value to show. Long text wraps onto several lines.
Label.builder("info")
.text(() -> Text.translatable("mymod.info", "%s profiles saved", profiles.size()))
.build();
Builder#
| Method | Required | Default | Notes |
|---|---|---|---|
text(Supplier<Text>) / text(Text) |
yes | re-read on every refresh | |
enabled, tooltip, visible |
no | options every widget has |
Behaviour#
- For the outcome of an action ("Saved", "Couldn't write the file"), use a StatusLine instead: it has a severity color and starts empty.
- A non-collapsible Section is drawn as a label, so use a section for a heading above a group.
- Footer: yes.
Test it#
Rendered as [label info] 3 profiles saved.
See also#
- Javadoc: Label