Skip to content

Tab panels

Juuxel edited this page Jul 23, 2022 · 2 revisions

Tab panels (WTabPanel) are panels that, a bit like a web browser, have tabs on the top. For example, you could use one to display multiple sections of a machine GUI.

You can add tabs to a tab panel using WTabPanel.add:

WTabPanel tabs = new WTabPanel();
tabs.add(panelA, tab -> tab.icon(new ItemIcon(new ItemStack(Items.APPLE))));
tabs.add(panelB, tab -> tab.title(Text.translatable("gui.my_mod.panel_b")))
tabs.add(panelC, tab -> tab.title(Text.literal("Hello!")).icon(new ItemIcon(new ItemStack(Items.BREAD))).tooltip(Text.literal("I am a tooltip!")));

Note that each tab has to have at least a title or an icon.