WebLib (web_lib) is a lightweight library mod that lets mod developers build fully-featured Minecraft GUI screens using standard HTML and CSS, with a simple JavaScript-to-Java callback bridge — all rendered natively via Minecraft's own GuiGraphics, with zero external browser dependencies.
Stop wrestling with Minecraft's widget system. Write your mod's menus the way web developers write interfaces.
div, p, h1–h6, span, button, input, select, img, ul/ol/li, pre, hr, code, and more.margin, padding, border, width, height)flex-direction, justify-content, align-items, flex-wrap, gap)#RGB, #RRGGBB, #RRGGBBAA, rgb(), rgba(), named colors):hover, :active, :focus, :nth-child, :not, etc.), and all combinatorsonclick/onchange events. Pass arguments, access and mutate the DOM from Java.alert(), navigate(), reload(), setStyle(), setInnerText(), toggleClass(), setVar(), console.log() — no registration needed.namespace:path ResourceLocation convention.WebLibApi.openPageFromResource(...).WebPage API — Build, inject CSS, mutate, and layout pages programmatically before opening them.Adding WebLib to your mod is a single dependency declaration:
[[dependencies.yourmod]]
modId = "web_lib"
type = "required"
versionRange = "[1.0,)"
ordering = "AFTER"
side = "CLIENT"
Then open any screen with a single call:
WebLibApi.openPage("<html><body><h1>Hello, Minecraft!</h1></body></html>");
Register Java functions that HTML can call:
WebLibApi.registerFunction("myMod.openShop", (args, ctx) -> {
Minecraft.getInstance().tell(() -> Minecraft.getInstance().setScreen(new MyShopScreen()));
return null;
});
Available on GitHub under the Apache 2.0 License. Contributions welcome!
