back
87 comments
I wrote a little demo to run microui on top of the sokol headers here, it's really interesting in how minimal it is.

WASM demo: https://floooh.github.io/sokol-html5/sgl-microui-sapp.html

Source code: https://github.com/floooh/sokol-samples/blob/master/sapp/sgl...

The renderer backend is just a bunch of C functions you need to provide:

https://github.com/floooh/sokol-samples/blob/3f4185a8578cd2b...

It's also interesting to compare the binary sizes:

microui sample (https://floooh.github.io/sokol-html5/sgl-microui-sapp.html): 79.6 KBytes compressed download

Nuklear sample (https://floooh.github.io/sokol-html5/nuklear-sapp.html): 155 kb compressed download

Dear ImGui sample (https://floooh.github.io/sokol-html5/imgui-sapp.html): 491 KB compressed download

I made my own WASM demo @ https://microui-wasm.vercel.app/ and it's only 14.6 kB compressed!

Will share source code if someone is interested, but key bits:

- had a small JS glue layer using CanvasRenderingContext2D to render

- made a `wasm32-freestanding` build to lower the wasm bundle size, which meant shimming the bits of the libc microui uses

Why is the WASM demo so fuzzy? I am on Windows/Firefox.

https://imgur.com/uy78t52

pretty nifty but im trying to figure out what the use case for this is when its aimed at hobbyists ?

I use pygtk and dont have to fiddle with lower level stuff

I asked Claude to write one from scratch. A few minutes later it was done with exactly the features I needed. I started with some existing one, but when it couldn't handle multiple pointers (2 hands in VR/AR each with a pointer) without major mods I end up asking Claude if it could replace it with a custom one.

It first said "that's a ton of work" to which I said, "Really? A basic IMGUI needs a texture with glyphs. The abiltiy to draw textured rectangles with vertex colors. Scissor support for clipping. Some hit testing." and it was like, "yea, you're right", and a few mins later it wrote what I needed.

I'm not saying you shouldn't use this library.

This has been my goto for personal toy projects for a while now. Trivial to slot in to basically anything that can display text and takes mouse input.

I will mention, however, it's kinda abandonware at this point. There is some bug with the draw call iterator which does a misaligned pointer access, which, if your environment is set up to catch that, can get annoying (Zig for example panics on it). There's a github issue that some have used as reason to fork it but all the forks I tried were subtly wrong, for what that's worth.

The whole thing's less than 2kLoCs. If it needs ongoing maintenance, something's gone wrong IMO.

I think it's reasonable to just patch it yourself if it doesn't work with your other tools (Zig). Though thank you for sharing the heads up.

Genuine question; abandonware or complete? Something of this size serves as a nice substrate or starting-point regardless.
> it's kinda abandonware at this point

That's sad. I'm a fan of rxi's work, including this one.

I used this one in 2022 to make a proof of concept for a build once / run anywhere graphical app and IIRC the library was quite nice, even if a bit limited. The resulting kludge is at https://github.com/jacereda/cosmogfx and there's a prebuilt binary that should run on Linux, Windows and some BSDs. https://github.com/jacereda/cosmogfx/releases/download/v0.0....

Cosmopolitan Libc has since integrated the bits to make OpenGL work in cross-platform binaries and it's awesome.

This is included in the Odin vendor libraries, it's fantastic for Raylib debug menus
Raylib also has Raygui

https://github.com/raysan5/raygui

But I found it pretty straightforward (and satisfying) to just build my own gui functions/widgets with raylib (inspired by raygui).

https://github.com/dsego/strobe-tuner/blob/main/app/gui.odin

For a slightly larger, cross-platform, retained mode GUI written in C, there's libagar [0]. Different use case than MicroUI, but still a neat project.

[0] https://libagar.org/

If that's your project, the Arabic text rendering is broken in this screenshot:

https://libagar.org/screenshots/agar171.png

Cool to see a demo in there that you can run in a browser, presumably compiled to WebAssembly. The kind of thing that was unimaginable years ago.
>"Features

o Tiny: around 1100 sloc of ANSI C

o Works within a fixed-sized memory region: no additional memory is allocated

o Built-in controls: window, scrollable panel, button, slider, textbox, label, checkbox, wordwrapped text

o Works with any rendering system that can draw rectangles and text

o Designed to allow the user to easily add custom controls

o Simple layout system"

love the web assembly demo. By the way, I hope this kind of interface for the web becomes more mainstream in the future, I start to hate html / css cuz everything looks the same because of it (even in the train stations they use it for scheduling)
I've created a similar (minimal, lightweight, ANSI C) UI library, which is even easier to use.

https://gitlab.com/bztsrc/smgui

I don't like immediate-mode, because you must handle everything in the same thread, so mine is a state-mode GUI.

For immediate-mode and ANSI C, there's also Nuklear:

https://github.com/Immediate-Mode-UI/Nuklear

This latter has all the bells and whistles.

The first thing I look for in any UI library is accessibility support. Makes it trivial to filter out toy projects.
"Accessibility" is an open-ended set of functionality, not a checkbox; it is never "complete", there is always room for improvement. Colorblind support (which ones)? High-Contrast mode? Adjustable text size? Screenreader integration? Localization? IME support? Keyboard navigation? Keyboard remapping? Functional entirely without a keyboard? Touch support? Pen support? Dyslexia-aiding typefaces? The list goes on and on.
No. As much as I would like it to be the case, that is most certainly a poor criteria to evaluate a UI library.

Dear ImGui [0] is without a doubt the most prevalent immediate mode UI library. It does not have native accessibility features, but that hasn't stopped companies such as Intel, Meta, IKEA and Google from shipping products built upon it. It's also used in a ton of games.

Calling Dear ImGui a toy project at this point would be like calling Unreal Engine a toy project.

It's a shame accessibility support is not more widespread, and furthermore it's a shame that it is so laborious to add it.

0: https://github.com/ocornut/imgui/

This is a library in similar vein to "Dear imgui", minimal requirements for integration (rectangle and text rendering) so that it's easy to embed into game-engines,etc for debug UI's and similar things.
Not very smart. I would go further and say that even full unicode support could be avoided and a software can still be massively useful.

It is sad that the world is so hung up on unicode and things like accessibility that we all have to submit to the tyranny of browser layers!

Or, not every UI library is intended for use cases where a13y even makes sense.

Like a debug UI in a game engine, or in an embedded device that doesn't even have input for a13y.

Everything is an engineering decision. Leaving out something doesn't mean it's a "toy". So, I don't really get your criticism here.
Windows XP has better accessibility than anything since, by virtue of staying entirely out of the way of accessibility tools. Time to downgrade!
Is there any game engine out there with good accessibility support for their UI?
What? On a micro immediate mode UI?

Really insane comment TBH

Then just save yourself some time. Immediate mode and accessibility are mutually exclusive.
I agree, and the lack of empathy around this area is sad. If you're developing an app, it is better to fall into the pit of success by using a UI framework that already has accessibility baked in. Any project that uses Dear Imgui for end-user applications has already made a bad design choice. AccessKit (https://accesskit.dev/) seems to be a positive step forward, with some UI frameworks implemented (including immediate mode egui).
How can such a library be both tiny and portable, when the C standard library has no graphics facilities? Don't you need to lay down a lot of basis for different platforms and graphics backends, to be portable? And if you do that, how can you be tiny?
Almost all of these immediate mode UI libraries for C/C++ come without a rendering backend. Usually there are "example" implementations for libraries like SDL that you can use, or you implement your own backend. A lot of these libraries are popular for debug UIs in games and you probably need a custom backend for whatever graphics engine you use in your game.
I just ported it to rust 1:1 (https://github.com/ioma8/microui-rs) Yes with assistance of AI, not ashamed of that.
What is the advantage of this compared to Dear Imgui?
it's lighter weight and written in C
I need something like this but with a few more bells and whistles.
The problem is always: you don't know beforehand what bells and whistles you will need. That's why Qt is probably the only safe bet (or Web/Electron if you don't mind the slower performance).
how is this different from lvgl? is this immediate mode or retained mode?
Very different, starting at the line count:

Lvgl is 440kloc across 1134 files (in the src directory), while microui is 1121 lines of code in one .c and one .h file.

Microui is immediate mode, very minimal and 'bring your own renderer'. Probably most useful for adding a small debugging UI to a 3D game/app.

anyone working on bindings to other languages? (go, python, ruby, etc)
I was just thinking this would be great with go. If it would work.
Nice, except the hard part seems to be missing: interfacing with an actual window system (X11, TUI, WIN32, whatever ...)
That's the whole point!

You plug it into your project and it can be rendered on anything that can push pixels and/or triangles to the screen. Events from windowing system go in, list of triangles comes out.

This is intended to be used with OpenGL, Vulkan, D3D and other graphics environment and used in cases where integrating a "real" GUI toolkit would be more trouble than it's worth.

Other popular libs like Dear Imgui or Egui work the same way.

It's a "bring your own renderer" UI framework, just like Dear ImGui or Nuklear. In some situation (e.g. when adding debugging UIs to a game) this is actually a big advantage compared to the renderer being baked into the library, since the game already has a renderer subsystem which the UI can easily hook into.
In demo/ someone can "steal" the renderer part which, being based on SDL, is to some extent cross-platform.
this is easy

question is how produce sms-message like text widget, with alligment like iphone

Immediate-mode in pure C is a nice constraint. how does it handle text rendering, do you bring your own atlas or is there something built in? Thats usually the part that balloons the dependency footprint.