Your first window
A storage screen with a search field, a filtered list and two buttons. You describe it, Galdur UI lays it out: no coordinates, no sizes.
You need a mod for Minecraft 1.21.1 and NeoForge 21.1 (Java 21), with Galdur UI as a dependency. If that's not done yet, follow Installation.
Create the window
Everything starts with GaldurLib.createWindow(). It returns an empty window.
GaldurWindow window = GaldurLib.createWindow();window.addTitle(Component.literal("Storage"), true); // true = centredElements are stacked top to bottom, in the order you add them. Theme, spacing and size are handled for you.
Add a search field and a list
Every add… method returns a handle. A ListHandle holds the lines and the selected line, and you can change them while the window is open.
List<String> ores = List.of("Coal", "Iron", "Copper", "Gold");SearchHandle search = window.addSearch(Component.literal("Search..."));ListHandle list = window.addList(4); // 4 lines visiblelist.setLines(ores.stream().<Component>map(Component::literal).toList());search.onChange(text -> list.setLines(ores.stream() .filter(ore -> ore.toLowerCase().contains(text.toLowerCase())) .<Component>map(Component::literal).toList()));To react when the player picks a line, use onSelect. When the lines are replaced, the selection is cleared and onSelect receives -1.
Add buttons in a row
By default, elements go one below the other. addRow puts them side by side. Here the row is centred.
RowHandle buttons = window.addRow(true);buttons.addButton(Component.literal("Take"), () -> take(list.getSelected()));buttons.addButton(Component.literal("Close"), window::close);Open it
window.open() shows the window on the next client tick. Escape or window.close() go back to the screen that was open before. Try it:
Windows, widgets, screens and the theme are client-only. Only api.menu loads on a dedicated server: open windows from client code (a key mapping, a client command), never from server code.
Everything you can add
Each method below also has an overload with a final boolean centered parameter. Rows accept text, buttons, icon buttons and checkboxes.
| Method | Returns | Adds |
|---|---|---|
addTitle(text) | ElementHandle | A title, in the Fredoka title font. |
addText(text) | ElementHandle | A line of text. |
addButton(label, action) | ElementHandle | A button. The action runs on click and on Enter. |
addIconButton(icon, label, action) | ElementHandle | A button with an item or a sprite. The label becomes the tooltip. |
addCheckbox(label, checked) | CheckboxHandle | A checkbox, with its state and onChange. |
addRow() | RowHandle | Elements side by side. |
addList(visibleRows) | ListHandle | A scrolling list with a selection. |
addSearch(placeholder) | SearchHandle | A text field, with onChange on every key. |
addProgress(label) | ProgressHandle | A progress bar, from 0 to 1 or done / total. |
addTabs() | TabsHandle | Tabs, each with its own content. Window only. |
Every handle can also disable, hide or give a tooltip to its element: see Handles.