What is Elementa?
Elementa is a modern, declarative UI framework for Minecraft that provides:- Constraint-based layout system
- Reactive state management
- Component composition
- Smooth animations
- Event handling
Getting Started
Adding Elementa
Elementa is included with Essential. Import it in your code:Basic Concepts
UIComponent
Everything in Elementa is aUIComponent:
Constraints
Constraints define how components are positioned and sized:Parent-Child Relationships
Components are organized in a tree:Elementa Versions
Always specify anElementaVersion for improved behavior:
Why Versions Matter
V0: Legacy behavior (deprecated)V1,V2,V3,V4: Progressive improvementsV5: Latest, with bug fixes and best practices
Common Components
UIBlock
A solid colored rectangle:UIText
Rendered text:UIWrappedText
Text that wraps to fit width:UIContainer
A container for other components:UIImage
Display images from resources or URLs:Constraint Types
Position Constraints
Size Constraints
Color Constraints
Layouts
Column Layout
Stack components vertically:Row Layout
Stack components horizontally:Grid Layout
Create a grid using constraints:State Management
Elementa provides reactive state for dynamic UIs:BasicState
Binding to States
Derived States
Event Handling
Mouse Events
Keyboard Events
Animations
Elementa supports smooth animations:Complete Example
Here’s a complete example using Elementa with Essential:Resources
Official Documentation
Learning Resources
The best way to learn Elementa is by:- Reading the official wiki
- Exploring Essential’s source code
- Experimenting with examples
Best Practices
Always Use ElementaVersion
Always Use ElementaVersion
Specify
ElementaVersion.V5 (or latest) for new code:Use DSL Extensions
Use DSL Extensions
Use the DSL for cleaner code:
Leverage State
Leverage State
Use Elementa states for reactive UIs instead of manual updates:
Chain Constraints
Chain Constraints
Use the constrain block to chain all constraints:
Use childOf for Clarity
Use childOf for Clarity
Use
childOf for clear parent-child relationships:Common Patterns
Centered Component
Responsive Container
Button with Hover Effect
List of Items
Related APIs
EssentialGUI
Pre-styled Essential base screen
Components
Pre-built UI components
Notifications
Display notifications