KontraKontra
    DocumentationAbout
Docs
  • Getting Started
  • Installation
  • Hello World
  • Ansi
  • Todo App
  • Event Handling
  • Style Builder
  • Components
  • Border
  • Button
  • Checkbox
  • Flex
  • Input
  • List
  • Radio Buttons
  • Tabs
  • Text
Getting StartedHello World
KontraKontra

Installation

Getting Kontra TUI into your project is designed to be simple, modern, and efficient - just like the terminal UIs you'll build with it. You've got two ways to integrate it, depending on your preferences.


Method 1: The Modern Way with CPM.cmake (Recommended ✨)

This is the fastest and cleanest way to use Kontra - no cloning, no hassle. It fetches the library automatically during the CMake configuration step.

Prerequisites:

  • A C++17 compatible compiler.
  • CMake version 3.16 or higher.

Step 1: Download CPM.cmake

Download the latest CPM.cmake from CPM Github by following the steps given and place it in a cmake/ folder in your project.

Step 2: Add Kontra to your CMakeLists.txt

Step 3: Build

You're done! 🚀


📦 Method 2: The Classic Way with git submodule

Use this method if you prefer to track Kontra directly in your repository or want to work offline.

Prerequisites:

  • git
  • A C++17 compatible compiler
  • CMake 3.16+

Step 1: Add Kontra as a Git Submodule

Resulting structure:


  YourCoolApp/
  ├── main.cpp
  ├── CMakeLists.txt
  └── external/
      └── kontra/

Step 2: Modify CMakeLists.txt

Step 3: Build


Still deciding?
🔰 Use CPM.cmake if you want ease of setup and automatic updates.
🔒 Use submodules if you want local control and version locking.

Either way, you're just a few lines away from building stylish terminal apps in C++. ✨


  cmake -S . -B build
  cmake --build build


  git submodule add https://github.com/parv141206/kontra.git external/kontra
  git submodule update --init --recursive


  cmake -S . -B build
  cmake --build build


  # YourCoolApp/CMakeLists.txt

  cmake_minimum_required(VERSION 3.16)
  project(YourCoolApp LANGUAGES CXX)

  set(CMAKE_CXX_STANDARD 17)
  set(CMAKE_CXX_STANDARD_REQUIRED ON)

  # Tell CMake where CPM.cmake is
  list(APPEND CMAKE_MODULE_PATH "\${CMAKE_CURRENT_SOURCE_DIR}/cmake")
  include(cmake/CPM.cmake)

  # ✨ Fetch Kontra from GitHub
  CPMAddPackage(
      NAME Kontra
      GITHUB_REPOSITORY parv141206/kontra
      GIT_TAG master
  )

  add_executable(YourCoolApp main.cpp)

  # Link Kontra
  target_link_libraries(YourCoolApp PRIVATE kontra)


  # YourCoolApp/CMakeLists.txt

  cmake_minimum_required(VERSION 3.16)
  project(YourCoolApp LANGUAGES CXX)

  set(CMAKE_CXX_STANDARD 17)
  set(CMAKE_CXX_STANDARD_REQUIRED ON)

  # 📦 Add Kontra from local subdirectory
  add_subdirectory(external/kontra)

  add_executable(YourCoolApp main.cpp)

  # Link Kontra
  target_link_libraries(YourCoolApp PRIVATE kontra)