logoalt Hacker News

MicroUI – A tiny, portable, immediate-mode UI library written in ANSI C

123 pointsby peter_d_shermantoday at 12:04 PM40 commentsview on HN

Comments

flohofwoetoday at 3:42 PM

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

show 1 reply
kartoffelsafttoday at 2:04 PM

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.

show 2 replies
jaceredatoday at 5:24 PM

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.

kettleztoday at 2:50 PM

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

show 1 reply
abtinftoday at 1:11 PM

The first thing I look for in any UI library is accessibility support. Makes it trivial to filter out toy projects.

show 8 replies
em-beetoday at 6:22 PM

anyone working on bindings to other languages? (go, python, ruby, etc)

show 1 reply
afavourtoday at 2:05 PM

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.

OvervCWtoday at 2:21 PM

What is the advantage of this compared to Dear Imgui?

show 1 reply
synergy20today at 1:50 PM

how is this different from lvgl? is this immediate mode or retained mode?

show 1 reply
ur-whaletoday at 1:10 PM

Nice, except the hard part seems to be missing: interfacing with an actual window system (X11, TUI, WIN32, whatever ...)

show 3 replies
peter_d_shermantoday at 12:06 PM

>"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"

Litticetoday at 12:16 PM

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.

show 2 replies