Skip to content

Support ANSI 16 color codes for borderColor and backgroundColor #852

@AlexZeitler

Description

@AlexZeitler

Problem

Currently, borderColor and backgroundColor on BoxRenderable are rendered using true color escape sequences (\e[38;2;r;g;bm). This means the colors are absolute RGB values that don't adapt to the user's terminal color scheme.

ANSI 16 color codes (\e[31m, \e[41m, etc.) are mapped by the terminal emulator to its configured palette, so an app can automatically adapt to the user's theme — especially important over SSH where the client terminal defines the colors.

Current behavior

  • fg() styled text supports ANSI named colors via red(), blue(), cyan() etc.
  • borderColor and backgroundColor accept ColorInput but always render as true color, even when a named color like "red" is passed — parseColor converts it to a fixed RGB value (rgba(1,0,0))

Expected behavior

When a named ANSI color (e.g. "red", "blue", "brightCyan") is used as borderColor or backgroundColor, it should emit the corresponding ANSI 16 escape code instead of a true color sequence, so the terminal can map it to its palette.

Use case

Building a TUI app that respects the user's terminal theme out of the box, without requiring manual color configuration. This is standard behavior in tools like lazygit and other popular terminal apps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreThis relates to the core packagefeatureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions