Kontra logo

Kontra

Build wicked terminal UIs in raw C++

Components

Packed with
  • ⚡ snappy,
  • 🛠️ customizable,
  • and 🖥️ terminal-native UI
components.
Build clean CLIs without breaking a sweat!
Border
Button
Flex
Input
List
Text

    inline constexpr const char* RESET = "\033[0m";
    inline constexpr const char* BOLD = "\033[1m";
    inline constexpr const char* DIM = "\033[2m";
    inline constexpr const char* ITALIC = "\033[3m";
    inline constexpr const char* UNDERLINE = "\033[4m";
    inline constexpr const char* INVERSE = "\033[7m";
    inline constexpr const char* STRIKETHROUGH = "\033[9m";
    ...
    inline constexpr const char* FG_BLACK = "\033[30m";
    inline constexpr const char* FG_RED = "\033[31m";
    inline constexpr const char* FG_GREEN = "\033[32m";
    inline constexpr const char* FG_YELLOW = "\033[33m";
    ...
    inline constexpr const char* BG_BLACK = "\033[40m";
    inline constexpr const char* BG_RED = "\033[41m";
    inline constexpr const char* BG_GREEN = "\033[42m";
    inline constexpr const char* BG_YELLOW = "\033[43m";
    ...

And many more!

Hardcore Utilities

Kontra ships with a Swiss army knife of styling tools.

Tweak, theme, and supercharge your TUI components with ease.

No macros. No bloat. Just raw control and clean C++.

Customizability

Tweak every pixel - from colors and borders to boldness and behavior.

Kontra hands you builder-style APIs for ultimate control. Not just usable - custom-crafted.


  #include "../include/kontra.hpp"
  #include "../include/core/utils.hpp" 

  int main() {
      ...
      auto button1 = std::make_shared<Button>(
          "Set Message 1",
          [&]() { message = "Button 1 was clicked!"; },
          ButtonStyleBuilder()
          .set_color(ansi::FG_WHITE)
          .set_background_color(ansi::BG_BLUE)
          .set_color_active(ansi::FG_BLUE)
          .set_background_color_active(ansi::BG_BRIGHT_WHITE)
          .set_bold(true)
          .build()
      );
      ...
  }


  #include "../include/kontra.hpp"
  #include "../include/core/utils.hpp"

  int main() {
    ...
    kontra::run(screen, [&](const InputEvent& event) {
        if (event.type == EventType::KEY_PRESS) {
            if (event.key == 17) exit(0); // Ctrl+Q

            switch (event.key) {
                case '1': add_button->click(); break;
                case '2': remove_button->click(); break;
                case '3': clear_button->click(); break;
                case 'j': // Down
                    if (!tasks.empty() && selected_task < tasks.size() - 1) {
                        selected_task++;
                        update_task_list();
                    }
                    break;
                case 'k': // Up
                    if (selected_task > 0) {
                        selected_task--;
                        update_task_list();
                    }
                    break;
                default:
                    input_box->handle_input(event.key);
                    break;
            }
        }
    });
    ...
  }

Interactivity

Hook into raw keypresses and map them to actions - no black-box magic, just clean C++ logic.

Build apps that feel alive in the terminal - fast reactions, tight control, full interactivity.

Dive into the Docs

Ready to build legendary CLIs? 🧙‍♂️ The docs are your spellbook.

Layouts, inputs, styles - all minimal, all documented, all yours.

Crack it open, copy a snippet, and ⚡ boom - terminal UI magic.

Made with 🤍 by parv141206