Convert Figma logo to code with AI

rxi logomicroui

A tiny immediate-mode UI library

3,408
240
3,408
29

Top Related Projects

59,344

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies

9,077

A single-header ANSI C immediate mode cross-platform GUI library

13,679

A single-header ANSI C gui library

10,698

Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.

3,379

A simple and easy-to-use immediate-mode gui library

Quick Overview

microui is a tiny, portable, immediate-mode UI library written in ANSI C. It's designed to be simple, lightweight, and easy to integrate into existing projects, making it ideal for small games or applications that require a basic GUI.

Pros

  • Extremely lightweight and minimal (single header file)
  • Easy to integrate into existing projects
  • No external dependencies
  • Highly portable, works on various platforms

Cons

  • Limited set of UI elements compared to more comprehensive libraries
  • Lacks advanced styling options
  • No built-in theming system
  • Requires manual rendering implementation

Code Examples

Creating a simple window:

mu_Container window;
mu_begin(&ctx);
if (mu_begin_window(&ctx, &window, "My Window")) {
    mu_label(&ctx, "Hello, World!");
    mu_end_window(&ctx);
}
mu_end(&ctx);

Adding a button with a click event:

if (mu_button(&ctx, "Click me!")) {
    printf("Button clicked!\n");
}

Creating a slider:

static float value = 0.5f;
mu_slider(&ctx, &value, 0, 1);

Getting Started

  1. Download microui.h and microui.c from the repository.
  2. Include the files in your project:
#define MICROUI_IMPLEMENTATION
#include "microui.h"

// Your rendering implementation
void render_func(mu_Rect rect, mu_Color color) {
    // Implement rendering here
}

int main(void) {
    mu_Context ctx;
    mu_init(&ctx);
    ctx.text_width = text_width;
    ctx.text_height = text_height;

    // Your main loop
    while (1) {
        // Handle input
        // Update microui
        mu_begin(&ctx);
        // Your UI code here
        mu_end(&ctx);
        // Render
    }

    return 0;
}

Note: You'll need to implement rendering functions and input handling to fully integrate microui into your project.

Competitor Comparisons

59,344

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies

Pros of ImGui

  • More feature-rich with extensive UI elements and customization options
  • Larger community and ecosystem, with numerous bindings and extensions
  • Better documentation and examples for various use cases

Cons of ImGui

  • Larger codebase and higher complexity, potentially harder to integrate
  • Higher memory footprint and performance overhead for simple applications
  • Steeper learning curve for beginners due to its extensive API

Code Comparison

MicroUI:

mu_begin(ctx);
if (mu_button(ctx, "Hello")) {
  printf("Button pressed\n");
}
mu_end(ctx);

ImGui:

ImGui::Begin("Window");
if (ImGui::Button("Hello")) {
  std::cout << "Button pressed" << std::endl;
}
ImGui::End();

Summary

MicroUI is a lightweight, simple-to-use immediate mode GUI library, while ImGui offers a more comprehensive set of features and wider adoption. MicroUI is better suited for small projects or resource-constrained environments, whereas ImGui excels in larger applications requiring advanced UI capabilities. The code comparison shows that both libraries share a similar immediate mode paradigm, but ImGui's syntax is slightly more verbose due to its C++ nature and additional features.

9,077

A single-header ANSI C immediate mode cross-platform GUI library

Pros of Nuklear

  • More comprehensive feature set, including advanced widgets and layout options
  • Better cross-platform support and integration with various rendering backends
  • Larger community and more frequent updates

Cons of Nuklear

  • Larger codebase and higher complexity, potentially harder to integrate
  • Steeper learning curve due to more extensive API
  • Higher memory footprint compared to microui

Code Comparison

microui:

mu_begin(ctx);
if (mu_button(ctx, "Hello")) {
    printf("Button pressed\n");
}
mu_end(ctx);

Nuklear:

if (nk_begin(ctx, "Window", nk_rect(50, 50, 200, 200),
    NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
    NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))
{
    if (nk_button_label(ctx, "Hello")) {
        printf("Button pressed\n");
    }
}
nk_end(ctx);

Both libraries offer immediate mode GUI functionality, but Nuklear provides more advanced features and customization options at the cost of increased complexity. microui focuses on simplicity and minimal overhead, making it easier to integrate into smaller projects or those with limited resources.

13,679

A single-header ANSI C gui library

Pros of Nuklear

  • More comprehensive feature set, including advanced widgets and layout options
  • Wider platform support and integration with various rendering backends
  • Larger community and more frequent updates

Cons of Nuklear

  • Steeper learning curve due to its complexity and extensive API
  • Larger codebase and memory footprint
  • More challenging to customize and extend

Code Comparison

Nuklear:

struct nk_context ctx;
nk_init_default(&ctx, 0);
if (nk_begin(&ctx, "Demo", nk_rect(50, 50, 200, 200),
    NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
    NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))
{
    nk_layout_row_dynamic(&ctx, 30, 1);
    if (nk_button_label(&ctx, "Button")) {
        // Button clicked
    }
}
nk_end(&ctx);

Microui:

mu_Context ctx;
mu_init(&ctx);
if (mu_begin_window(&ctx, "Demo", mu_rect(50, 50, 200, 200))) {
    if (mu_button(&ctx, "Button")) {
        // Button clicked
    }
    mu_end_window(&ctx);
}

The code comparison shows that Microui has a simpler API with fewer options, while Nuklear offers more granular control over window properties and layout.

10,698

Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.

Pros of libui

  • Cross-platform native GUI toolkit for multiple languages (C, C++, Go, etc.)
  • Provides a more comprehensive set of UI controls and widgets
  • Better suited for complex, full-featured desktop applications

Cons of libui

  • Larger codebase and more complex to integrate
  • Steeper learning curve for beginners
  • May be overkill for simple GUI applications or prototypes

Code Comparison

microui example:

mu_begin(ctx);
if (mu_begin_window(ctx, "My Window", mu_rect(10, 10, 200, 100))) {
  mu_label(ctx, "Hello world!");
  mu_end_window(ctx);
}
mu_end(ctx);

libui example:

uiInit(&options);
uiWindow *window = uiNewWindow("My Window", 200, 100, 0);
uiLabel *label = uiNewLabel("Hello world!");
uiBoxAppend(uiNewVerticalBox(), uiControl(label), 0);
uiWindowSetChild(window, uiControl(box));
uiControlShow(uiControl(window));
uiMain();

microui is more lightweight and easier to integrate for simple GUIs, while libui offers more features and native look-and-feel across platforms at the cost of increased complexity.

3,379

A simple and easy-to-use immediate-mode gui library

Pros of raygui

  • More comprehensive feature set with a wider range of UI elements
  • Integrated with the raylib game programming library for seamless integration
  • Active development and community support

Cons of raygui

  • Larger codebase and potentially higher memory footprint
  • Steeper learning curve due to more complex API

Code Comparison

microui:

mu_begin(ctx);
if (mu_button(ctx, "Hello")) {
    printf("Button pressed\n");
}
mu_end(ctx);

raygui:

GuiSetStyle(DEFAULT, TEXT_SIZE, 20);
if (GuiButton((Rectangle){ 50, 50, 100, 30 }, "Hello")) {
    printf("Button pressed\n");
}

Summary

microui is a minimalist immediate mode GUI library, focusing on simplicity and small code size. raygui offers a more feature-rich GUI toolkit integrated with raylib, providing a wider range of UI elements and styling options. While microui is easier to integrate into existing projects due to its simplicity, raygui may be more suitable for larger applications or those already using raylib. The choice between the two depends on project requirements, existing technology stack, and desired level of customization.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

microui

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

Features

  • Tiny: around 1100 sloc of ANSI C
  • Works within a fixed-sized memory region: no additional memory is allocated
  • Built-in controls: window, scrollable panel, button, slider, textbox, label, checkbox, wordwrapped text
  • Works with any rendering system that can draw rectangles and text
  • Designed to allow the user to easily add custom controls
  • Simple layout system

Example

example

if (mu_begin_window(ctx, "My Window", mu_rect(10, 10, 140, 86))) {
  mu_layout_row(ctx, 2, (int[]) { 60, -1 }, 0);

  mu_label(ctx, "First:");
  if (mu_button(ctx, "Button1")) {
    printf("Button1 pressed\n");
  }

  mu_label(ctx, "Second:");
  if (mu_button(ctx, "Button2")) {
    mu_open_popup(ctx, "My Popup");
  }

  if (mu_begin_popup(ctx, "My Popup")) {
    mu_label(ctx, "Hello world!");
    mu_end_popup(ctx);
  }

  mu_end_window(ctx);
}

Screenshot

screenshot

Browser Demo

Usage

  • See doc/usage.md for usage instructions
  • See the demo directory for a usage example

Notes

The library expects the user to provide input and handle the resultant drawing commands, it does not do any drawing itself.

Contributing

The library is designed to be lightweight, providing a foundation to which you can easily add custom controls and UI elements; pull requests adding additional features will likely not be merged. Bug reports are welcome.

License

This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.