ConsoleForge 0.3.0
Elm-architecture TUI framework for .NET 8
Loading...
Searching...
No Matches
ConsoleForge.Styling.ThemeExtensions Class Reference

Extension methods for Theme that give convenient, typed access to the colours and styles embedded in a theme's Style properties. More...

Static Public Member Functions

static ? IColor Accent (this Theme theme)
 Accent colour — the border-foreground colour from Theme.BorderStyle.
static Style AccentStyle (this Theme theme)
 Accent style suitable for headings and highlights.
static Style BaseColorStyle (this Theme theme)
 Returns a Style combining both the theme's foreground and background colours.
static ? IColor Bg (this Theme theme)
 Background colour from Theme.BaseStyle, or null if the theme does not specify one.
static Style BgStyle (this Theme theme)
 Returns a Style that applies the theme's background colour.
static Style Error (this Theme theme)
 Error / danger style (red or theme equivalent).
static ? IColor Fg (this Theme theme)
 Foreground colour from Theme.BaseStyle, or null if the theme does not specify one.
static ? IColor FocusColor (this Theme theme)
 Focus-ring colour — the border-foreground colour from Theme.FocusedStyle.
static Style GetStyle (this Theme theme, string key, Style fallback=default)
 Retrieve an arbitrary named style slot with a fallback.
static Style MutedStyle (this Theme theme)
 Muted / secondary-text style for hints, descriptions, and status text.
static Style SecondaryStyle (this Theme theme)
 Secondary style — slightly less prominent than muted.
static Style Success (this Theme theme)
 Success / positive-state style (green or theme equivalent).
static Style Warning (this Theme theme)
 Warning / caution style (yellow/orange or theme equivalent).

Detailed Description

Extension methods for Theme that give convenient, typed access to the colours and styles embedded in a theme's Style properties.

var t = Theme.Dracula;
// Pull raw colours for building explicit widget styles
IColor? bg = t.Bg(); // background from BaseStyle
IColor? fg = t.Fg(); // foreground from BaseStyle
IColor? acc = t.Accent(); // border-fg from BorderStyle (the brand/accent colour)
IColor? foc = t.FocusColor(); // border-fg from FocusedStyle
// Ready-made styles for common UI roles
Style heading = t.AccentStyle().Bold(true); // accent colour, bold
Style hint = t.MutedStyle(); // dim secondary text
Style ok = t.Success(); // green / equivalent per theme
Style bad = t.Error(); // red / equivalent per theme
// Arbitrary named slot with fallback
Style custom = t.GetStyle("my-widget", Style.Default.Foreground(Color.White));
Abstraction over ANSI/256/TrueColor values.
Definition Colors.cs:8
record Theme
Immutable named collection of base styles applied as defaults across all widgets via Style....
Definition Theme.cs:11
Immutable value type carrying visual style properties.
Definition Style.cs:12
static readonly Style Default
The empty style (no properties set). Fast path: Render returns text unchanged.
Definition Style.cs:66
Style Foreground(IColor color)
Returns a new style with the foreground color set to color .
Definition Style.cs:92
Style Bold(bool value=true)
Returns a new style with bold enabled or disabled.
Definition Style.cs:98

Member Function Documentation

◆ Accent()

? IColor ConsoleForge.Styling.ThemeExtensions.Accent ( this Theme theme)
static

Accent colour — the border-foreground colour from Theme.BorderStyle.

This is the theme's primary brand / highlight colour used for borders and headings. Returns null if the theme does not specify one.

◆ AccentStyle()

Style ConsoleForge.Styling.ThemeExtensions.AccentStyle ( this Theme theme)
static

Accent style suitable for headings and highlights.

Returns Named["accent"] if present; otherwise constructs a style with the Accent colour as foreground. Falls back to Style.Default when the theme has no accent.

◆ BaseColorStyle()

Style ConsoleForge.Styling.ThemeExtensions.BaseColorStyle ( this Theme theme)
static

Returns a Style combining both the theme's foreground and background colours.

All widgets placed inside a container that uses this style will inherit the full base palette.

◆ BgStyle()

Style ConsoleForge.Styling.ThemeExtensions.BgStyle ( this Theme theme)
static

Returns a Style that applies the theme's background colour.

When the theme has no background, returns Style.Default. Useful for setting a full-terminal background on the root container.

◆ Error()

Style ConsoleForge.Styling.ThemeExtensions.Error ( this Theme theme)
static

Error / danger style (red or theme equivalent).

Returns Named["error"] if present; otherwise Style.Default.

◆ FocusColor()

? IColor ConsoleForge.Styling.ThemeExtensions.FocusColor ( this Theme theme)
static

Focus-ring colour — the border-foreground colour from Theme.FocusedStyle.

Returns null if the theme does not specify one.

◆ GetStyle()

Style ConsoleForge.Styling.ThemeExtensions.GetStyle ( this Theme theme,
string key,
Style fallback = default )
static

Retrieve an arbitrary named style slot with a fallback.

Parameters
themeThe theme to query.
keyNamed style key (e.g. "muted", "accent").
fallbackStyle to return when the key is absent. Defaults to Style.Default.

◆ MutedStyle()

Style ConsoleForge.Styling.ThemeExtensions.MutedStyle ( this Theme theme)
static

Muted / secondary-text style for hints, descriptions, and status text.

Returns Named["muted"] if present; otherwise falls back to Theme.DisabledStyle.

◆ SecondaryStyle()

Style ConsoleForge.Styling.ThemeExtensions.SecondaryStyle ( this Theme theme)
static

Secondary style — slightly less prominent than muted.

Returns Named["secondary"] if present; otherwise falls back to MutedStyle.

◆ Success()

Style ConsoleForge.Styling.ThemeExtensions.Success ( this Theme theme)
static

Success / positive-state style (green or theme equivalent).

Returns Named["success"] if present; otherwise Style.Default.

◆ Warning()

Style ConsoleForge.Styling.ThemeExtensions.Warning ( this Theme theme)
static

Warning / caution style (yellow/orange or theme equivalent).

Returns Named["warning"] if present; otherwise Style.Default.


The documentation for this class was generated from the following file:
  • src/ConsoleForge/Styling/ThemeExtensions.cs