-
Notifications
You must be signed in to change notification settings - Fork 7
Label
Refaltor77 edited this page Mar 29, 2026
·
2 revisions
Text display element with font customization.
use refaltor\ui\elements\Label;
$label = Label::create("my_label", "Hello World!");$label->setFontSize(Label::FONT_SMALL); // Small text
$label->setFontSize(Label::FONT_NORMAL); // Default size
$label->setFontSize(Label::FONT_LARGE); // Large text
$label->setFontSize(Label::FONT_EXTRA_LARGE); // Extra large$label->setFontType(Label::TYPE_DEFAULT); // Standard font
$label->setFontType(Label::TYPE_RUNE); // Enchanting runes
$label->setFontType(Label::TYPE_UNICODE); // Unicode font
$label->setFontType(Label::TYPE_SMOOTH); // Smooth font
$label->setFontType(Label::TYPE_MINECRAFT_TEN); // MinecraftTen (title font)$label->setFontScaleFactor(2.0); // Scale text by 2x$label->setShadow(); // Enable shadow
$label->setShadow(false); // Disable shadowuse refaltor\ui\colors\BasicColor;
$label->setColor(BasicColor::yellow());
$label->setColor(BasicColor::rgb(0.5, 0.8, 0.2));
$label->setColor([1.0, 0.0, 0.0]); // Direct RGB array$title = Label::create("game_title", "My Game")
->setFontSize(Label::FONT_EXTRA_LARGE)
->setFontType(Label::TYPE_MINECRAFT_TEN)
->setFontScaleFactor(1.5)
->setShadow()
->setColor(BasicColor::yellow())
->setAnchorFrom(Element::ANCHOR_TOP_MIDDLE)
->setAnchorTo(Element::ANCHOR_TOP_MIDDLE)
->setOffset(0, 10);
$root->addElement($title);// Dynamic text from game data
$playerName = Label::create("name", "#localplayername")
->addBinding(Binding::global("#localplayername"))
->setColor(BasicColor::white());- Element — Base class properties
- BasicColor — Color utilities
- Binding — Dynamic text binding