Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AGenUI AGenUI Theme Config Loading

From Leeroopedia
Knowledge Sources
Domains Theming, UI_Framework
Last Updated 2026-10-24 17:21 GMT

Overview

Engine-level API for loading theme configuration (component property specs) and design token configuration into the AGenUI engine, provided by the AGenUI C++ core.

Description

The `loadThemeConfig()` and `loadDesignTokenConfig()` methods on `IAGenUIEngine` load two distinct configuration types:

`loadThemeConfig(themeConfig, result)`: delegates to `ComponentPropertySpecManager::loadFromString()`. The theme config JSON defines component property specifications — schemas describing what properties each component type supports, their types, and default values. This drives validation and property spec application during component parsing.

`loadDesignTokenConfig(designTokenConfig, result)`: delegates to `TokenParser::getInstance().loadFromJsonString()`. The design token config JSON defines the `{"designTokens": {...}}` map that the token parser uses for resolution.

Both methods: 1. Check engine is running (`_isRunning`). 2. Delegate to the respective subsystem. 3. On failure, set `result` to an error description string and return `false`.

Usage

  • Theme config: load once at app startup with component property spec JSON.
  • Design token config: load once at app startup with design token definitions.
  • Both: call before creating any surface manager for full effect.

Code Reference

Source Location

  • Repository: AGenUI
  • Interface: `core/include/agenui_engine.h:L106-119`
  • Implementation: `core/src/module/agenui_engine_impl.cpp:L224-248`

Signature

// core/include/agenui_engine.h
class IAGenUIEngine {
    // Load theme configuration (component property specs)
    // @param themeConfig Theme config JSON content
    // @param result Error content on failure
    // @return true on success, false on failure
    virtual bool loadThemeConfig(const std::string& themeConfig,
                                 std::string& result) = 0;

    // Load design token configuration
    // @param designTokenConfig Design token JSON: {"designTokens": {...}}
    // @param result Error content on failure
    // @return true on success, false on failure
    virtual bool loadDesignTokenConfig(const std::string& designTokenConfig,
                                       std::string& result) = 0;
};

Import

#include "agenui_engine.h"

I/O Contract

Inputs

Name Type Required Description
themeConfig `const std::string&` Yes Theme config JSON (component property specs)
designTokenConfig `const std::string&` Yes Design token JSON (`{"designTokens":{...}}`)

Outputs

Name Type Description
Both return true on success, false on failure
result Error description on failure

Usage Examples

Loading Theme and Design Tokens

auto* engine = agenui::initAGenUIEngine();
std::string error;

// Load theme config (component property specs)
std::string themeJson = R"({
    "Text": {
        "properties": {
            "text": {"type": "string", "required": true},
            "fontSize": {"type": "number", "default": 14}
        }
    }
})";
if (!engine->loadThemeConfig(themeJson, error)) {
    printf("Theme config error: %s\n", error.c_str());
}

// Load design token config
std::string tokenJson = R"({
    "designTokens": {
        "color_primary": {"type":"color","light":"#007AFF","dark":"#0A84FF"}
    }
})";
if (!engine->loadDesignTokenConfig(tokenJson, error)) {
    printf("Design token error: %s\n", error.c_str());
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment