Buttons and choices

button, button_accent and icon_button return true on the frame they are clicked. icon_button falls back to its label while the svg handle is not live, and icon_button_accent is the same in the accent role. checkbox and toggle both flip a bool* in place and are only drawn differently. radio compares its option value against a shared uint32_t*. tabs and segmented write the chosen index back from a fixed list of labels. tabs takes an optional flags, and tabs_vertical stands the strip up as a column that up and down walk, with labels start aligned. Every one of them returns true on the frame its value changes. In a right to left box tabs and segmented lay their first choice at the right and Left and Right swap, and vertical tabs align their labels to the right.

Button, a control that runs an action when pressed, drawn by isolenButton, a control that runs an action when pressed, drawn by isolen
widgets_buttons.cpp
#include "isolenui/ui/ui.h"
#include "isolenui/kit/kit.h"

struct panel_state {
    bool notify = true;
    bool dark = false;
    uint32_t quality = 0;
    uint32_t tab = 0;
};

static void controls(ui::ctx* u, panel_state* s, gfx_svg gear_icon)
{
    // button, a plain click
    if (ui::button(u, "rebuild atlas")) {
        // rebuild here
    }

    // button_accent, the same thing styled for the primary action
    if (ui::button_accent(u, "publish")) {
        // publish here
    }

    // icon_button, falls back to the label when the icon handle is not live
    if (ui::icon_button(u, gear_icon, "settings")) {
        // open settings here
    }

    // checkbox, toggles a bool in place
    ui::checkbox(u, "notify on finish", &s->notify);

    // toggle, the same bool but drawn as a switch
    ui::toggle(u, "dark mode", &s->dark);

    // radio, one of a small fixed set of options
    ui::radio(u, "low", 0u, &s->quality);
    ui::radio(u, "high", 1u, &s->quality);

    // tabs, a labelled strip that writes the chosen index back
    static const char* const tab_items[] = { "general", "audio", "video" };
    ui::tabs(u, tab_items, 3u, &s->tab);

    // segmented, the same idea drawn as one bordered strip
    static const char* const seg_items[] = { "list", "grid" };
    static uint32_t view_mode = 0;
    ui::segmented(u, seg_items, 2u, &view_mode);
}

Icons on buttons

  • button(u, icon, label) and button_accent(u, icon, label) put a 15 unit icon before the label, on the inline start, with a 7 unit gap, and centre the pair in the button. The icon takes the button's ink, so it follows hover, press and the accent role like the text does. In right to left the icon moves to the right of the label. GFX_NONE shows the label alone, the same as the plain overloads.
  • icon_button_flat(u, icon, label, id, side) is a quiet square icon button in role_flat. It has no fill at rest, a faint wash of the text colour on hover and focus, and a stronger one while pressed, so it reads on any surface, a raised card included. side is its size, and zero takes the theme row_h less 4. With icon at GFX_NONE it shows label instead.
  • An element is keyed by its label, so a button whose label changes would become a new control and lose its hover and focus. id keys icon_button_flat by a fixed string instead, so a copy button can turn into a copied tick and stay the same control. Null falls back to the label.
toolbar.cpp
#include "isolenui/ui/ui.h"
#include "isolenui/kit/kit.h"

struct toolbar {
    gfx_svg save_icon = GFX_NONE;
    gfx_svg copy_icon = GFX_NONE;
    gfx_svg check_icon = GFX_NONE;
    bool copied = false;
};

static void tools(ui::ctx* u, toolbar* t)
{
    ui_box(u, ui::row().gap(8.0f).items(lay_align_centre))
    {
        // the icon leads the label, GFX_NONE shows the label alone
        if (ui::button_accent(u, t->save_icon, "save")) {
            t->copied = false;
        }
        // one control under one id while its icon and label swap
        const gfx_svg icon = t->copied ? t->check_icon : t->copy_icon;
        if (ui::icon_button_flat(u, icon, t->copied ? "copied" : "copy", "copy")) {
            t->copied = true;
        }
    }
}

Last updated 6 October 2026