Skip to content
Immediate Mode User Interface for Haxe Kha
Branch: master
Clone or download
Latest commit d30c46a Jul 17, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
Sources/zui Adjust text color Jul 17, 2019
examples Update examples Mar 12, 2019 Breaking - updated api - check Feb 28, 2017 Update readme Mar 12, 2019 Zui.floatInput() is now Ext.floatInput() Oct 15, 2018


Portable immediate mode UI library designed for tools and debug interfaces. Written in Haxe and Kha, used in ArmorPaint.

Getting started

  • Clone into your_kha_project/Libraries
  • Add project.addLibrary('zui'); into khafile.js
	// In init()
	var ui = new Zui({ font: myFont });

	// In render()
	public function render(frames: Array<Framebuffer>) {
		var g = frames[0].g2;
		// Draw your stuff...
		if (ui.window(Id.handle(), x, y, w, h, drag)) {
			if (ui.button("Hello")) {

		// Draw more stuff...


function tab(id: Handle, text: String): Bool;
function panel(id: Handle, text: String, accent = 1): Bool;
function image(image: Image): State;
function text(text: String, align = Left, bg = 0);
function textInput(id: Handle, label = ""): String;
function button(text: String, align = Center, label = ""): Bool;
function check(id: Handle, text: String): Bool;
function radio(groupId: Handle, pos: Int, text: String): Bool;
function inlineRadio(id: Handle, texts: Array<String>): Int;
function combo(id: Handle, texts: Array<String>, label = ""): Int;
function slider(id: String, text: String, from: Float, to: Float, filled = false, precision = 100, displayValue = true): Float;
function tooltip(text: String);
function tooltipImage(image: Image);

// Formating
function row(ratios: Array<Float>);
function separator(h = 4, fill = true);
function indent();
function unindent();

Id.hx - simple macros to generate handles

var state = ui.check(Id.handle(), "Check Box");

Ext.hx - prebuilt elements:

function list(...); // See examples
function panelList(...);
function colorPicker(...);
function colorWheel(...); 
function fileBrowser(...);

Nodes.hx - drawing node systems

nodes.nodeCanvas(...); // See examples

Canvas.hx - drawing custom layouts

Canvas.draw(...); // See examples


Check out examples/ folder. To run specific example, simply drop it's folder into KodeStudio and hit run. If you are having trouble compiling, clone latest Kha repository into your example folder (alongside the khafile.js). This will let KodeStudio pick up the most recent Kha.


Themes can be defined using TTheme typedef. Check zui.Themes class for example. Set ZuiOptions.theme when creating new Zui instance to overwrite default theme.


Check element for changes

var hcombo = Id.handle();
ui.combo(hcombo, ["Item 1", "item 2"]);
if (hcombo.changed) {
	trace("Combo value changed this frame");

Force redrawing zui window on demand

function render(..) {
    // Get window handle
    var hwin = Id.handle();
    // Force redraw - set each frame or whenever desired
    hwin.redraws = 1;
    if (ui.window(hwin, x, y, w, h)) { ... }

Using render targets - prevent nested begin/end calls



zui.begin(); // Zui also draws to texture..


Using Id.handle() in a for loop

// Id.handle() works at compile time
// Call .nest() to get unique handle per iteration
for (i in 0...3) Id.handle().nest(i);
// Or use new zui.Handle() directly

Set initial Id.handle() state

var h1 = Id.handle({selected: true});
var h2 = Id.handle({position: 0});
var h3 = Id.handle({value: 1.0});
var h4 = Id.handle({text: "Text"});

Custom integration

Using the powerful render target system of Kha, it is possible to easily integrate the library into any scenario. Set ZuiOptions.autoNotifyInput to false when creating a new Zui instance. You can then manually process the input and render the resulting texture in any way you may need.

zui.onMouseDown(button:Int, x:Int, y:Int)
zui.onMouseUp(button:Int, x:Int, y:Int)
zui.onMouseMove(x:Int, y:Int, movementX:Int, movementY:Int)

Inspired by imgui.

You can’t perform that action at this time.