ktsu.ImGuiCredentialPopups 1.4.0

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package ktsu.ImGuiCredentialPopups --version 1.4.0
                    
NuGet\Install-Package ktsu.ImGuiCredentialPopups -Version 1.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ktsu.ImGuiCredentialPopups" Version="1.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ktsu.ImGuiCredentialPopups" Version="1.4.0" />
                    
Directory.Packages.props
<PackageReference Include="ktsu.ImGuiCredentialPopups" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ktsu.ImGuiCredentialPopups --version 1.4.0
                    
#r "nuget: ktsu.ImGuiCredentialPopups, 1.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ktsu.ImGuiCredentialPopups@1.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ktsu.ImGuiCredentialPopups&version=1.4.0
                    
Install as a Cake Addin
#tool nuget:?package=ktsu.ImGuiCredentialPopups&version=1.4.0
                    
Install as a Cake Tool

ktsu.ImGuiCredentialPopups

Ready-made Dear ImGui modal dialogs for collecting credentials.

License NuGet Version NuGet Version NuGet Downloads GitHub commit activity GitHub contributors GitHub Actions Workflow Status

Introduction

ktsu.ImGuiCredentialPopups provides drop-in modal dialogs for asking a user for credentials inside a Dear ImGui application. Rather than hand-rolling an input modal, masked text field, and confirm/cancel button pair for every application that needs to authenticate, you open a popup and receive a Credential back through a callback.

The credential types come from ktsu.CredentialCache, so what the popup hands you is ready to persist in the host's native keyring or pass straight to an API client.

Username and password, filled in

See the popup gallery for a picture of each popup.

Features

  • Username/Password Popup: UsernamePasswordPopup collects a username and a masked password and returns a CredentialWithUsernamePassword.
  • Token Popup: TokenPopup collects a single masked token value and returns a CredentialWithToken.
  • Shared Base Class: CredentialPopup handles the modal lifecycle, title and label configuration, and confirmation callback, so adding a new credential shape means overriding two methods.
  • Masked Input: Secret fields use ImGuiInputTextFlags.Password so values are never rendered in plain text.
  • Automatic Focus: The first input field receives keyboard focus when the modal opens, so the user can start typing immediately.
  • CredentialCache Integration: Results are ktsu.CredentialCache credential types, ready to store through an ICredentialStore.

Installation

Package Manager Console

Install-Package ktsu.ImGuiCredentialPopups

.NET CLI

dotnet add package ktsu.ImGuiCredentialPopups

Package Reference

<PackageReference Include="ktsu.ImGuiCredentialPopups" Version="x.y.z" />

Usage Examples

Basic Example

Create the popup once and keep it alive for the lifetime of the window, then call ShowIfOpen() every frame from your render loop.

using ktsu.CredentialCache;
using ktsu.ImGuiCredentialPopups;

private readonly UsernamePasswordPopup loginPopup = new();

private void OnRender()
{
    if (ImGui.Button("Sign in"))
    {
        loginPopup.Open("Sign in to GitHub", "Credentials", credential =>
        {
            CredentialWithUsernamePassword login = (CredentialWithUsernamePassword)credential;
            Authenticate(login.Username, login.Password);
        });
    }

    // Must be called every frame so the modal can draw itself.
    loginPopup.ShowIfOpen();
}

Collecting a Token

using ktsu.CredentialCache;
using ktsu.ImGuiCredentialPopups;

private readonly TokenPopup tokenPopup = new();

private void OnRender()
{
    if (ImGui.Button("Set access token"))
    {
        tokenPopup.Open("Personal Access Token", "Token", credential =>
        {
            CredentialWithToken token = (CredentialWithToken)credential;
            cache.Store("github", token);
        });
    }

    tokenPopup.ShowIfOpen();
}

Adding a Custom Credential Popup

Derive from CredentialPopup and supply the input UI and the credential it produces.

using ktsu.ImGuiCredentialPopups;

public class ApiKeyPopup : CredentialPopup
{
    private string apiKey = string.Empty;

    protected override bool ShowEdit()
    {
        ImGui.InputText("API Key", ref apiKey, 200, ImGuiInputTextFlags.Password);
        return false;
    }

    protected override Credential MakeCredential() =>
        new CredentialWithToken { Token = apiKey.As<CredentialToken>() };
}

API Reference

CredentialPopup

Abstract base class for credential input popups.

Properties
Name Type Description
Title string Title of the popup window.
Label string Label shown above the input fields.
Modal ImGuiPopups.Modal The underlying modal used to render the dialog.
Methods
Name Return Type Description
Open(string title, string label, Action<Credential> onConfirm) void Opens the popup and registers the callback invoked on confirmation.
ShowIfOpen() bool Renders the popup if it is open and returns whether it is open. Call once per frame.
ShowEdit() bool (protected, abstract) Draws the input fields. Returns true if the user completed input via a keyboard shortcut.
MakeCredential() Credential (protected, abstract) Builds the credential from the current input values.
CanConfirm bool (protected, virtual) Whether the current input values can be confirmed. While it is false, OK is disabled and Enter does not confirm. Defaults to true; TokenPopup requires a token and UsernamePasswordPopup requires both a username and a password.

UsernamePasswordPopup

CredentialPopup that collects a username and masked password, producing a CredentialWithUsernamePassword.

Name Return Type Description
Open(string title, string label, string username, Action<Credential> onConfirm) void Opens the popup with the username filled in and keyboard focus in the password field. The password always starts empty. Use it to retry after a rejected sign-in, or to ask for the password of a user the app already knows.

TokenPopup

CredentialPopup that collects a single masked token, producing a CredentialWithToken.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License. See the LICENSE.md file for details.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.1-pre.1 60 11/16/2026
1.4.0 107 11/13/2026
1.3.3-pre.2 57 11/12/2026
1.3.3-pre.1 59 11/11/2026
1.3.2 145 11/11/2026
1.3.1 291 10/10/2026
1.3.0 126 10/9/2026
1.2.26 124 10/9/2026
1.2.25 109 10/9/2026
1.2.25-pre.3 79 10/8/2026
1.2.25-pre.2 77 10/7/2026
1.2.25-pre.1 82 10/6/2026
1.2.24 146 10/6/2026
1.2.24-pre.3 76 10/5/2026
1.2.24-pre.2 79 10/1/2026
1.2.24-pre.1 94 9/30/2026
1.2.23 151 9/29/2026
1.2.23-pre.1 75 9/28/2026
1.2.22 126 9/25/2026
1.2.21 117 9/24/2026
Loading failed

## v1.4.0 (minor)

Changes since v1.3.0:

- Count a selection's room when deciding whether a paste fits, and put it back when the paste is rejected [patch] (#223) (matt-edmondson)
- Hand a confirmed credential to onConfirm after the modal is drawn [patch] (#224) (matt-edmondson)
- Keep OK and Enter from confirming a blank token, username or password [minor] (#225) (matt-edmondson)
- Let a username and password popup open with the username filled in [minor] (#226) (matt-edmondson)
- Report a paste too long for a credential field, and don't confirm while it shows [patch] (#215) (matt-edmondson)
- Trim a pasted token and username before returning them [patch] (#213) (matt-edmondson)
- Add CompatibilitySuppressions.xml for the Polyfill 11.4.5 shim drift [patch] (#211) (matt-edmondson)
- Accept a credential of exactly MaxCredentialLength bytes [patch] (matt-edmondson)
- Start a fresh showing on every Open, even while the popup is up [patch] (Claude)
- Show a popup from the gallery in the README (Claude)