Skip to content

ThemePanelWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A widget that applies theme customizations to its child widget tree. Use this to override theme elements (colors, characters, etc.) for a specific portion of your UI without affecting the rest of the application.

csharp
public sealed record ThemePanelWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<ThemePanelWidget>

Inheritance

ObjectHex1bWidgetThemePanelWidget

Implements

Constructors

ThemePanelWidget(Func<Hex1bTheme, Hex1bTheme>, Hex1bWidget)

A widget that applies theme customizations to its child widget tree. Use this to override theme elements (colors, characters, etc.) for a specific portion of your UI without affecting the rest of the application.

Parameters:

  • ThemeMutator (Func<Hex1bTheme, Hex1bTheme>): A function that receives a clone of the current theme and returns a (possibly modified) theme. The returned theme is used for rendering the child subtree. The theme is already cloned, so you can safely call Set() directly.
  • Child (Hex1bWidget): The child widget to render with the customized theme.
csharp
public ThemePanelWidget(Func<Hex1bTheme, Hex1bTheme> ThemeMutator, Hex1bWidget Child)

Properties

Child

The child widget to render with the customized theme.

Returns: Hex1bWidget

csharp
public Hex1bWidget Child { get; init; }

ThemeMutator

A function that receives a clone of the current theme and returns a (possibly modified) theme. The returned theme is used for rendering the child subtree. The theme is already cloned, so you can safely call Set() directly.

Returns: Func<Hex1bTheme, Hex1bTheme>

csharp
public Func<Hex1bTheme, Hex1bTheme> ThemeMutator { get; init; }

Examples

csharp
// Override button colors for this section only
ctx.ThemePanel(
    theme => theme
        .Set(ButtonTheme.ForegroundColor, Hex1bColor.White)
        .Set(ButtonTheme.BackgroundColor, Hex1bColor.Blue),
    ctx.VStack(v => [
        v.Button("Primary"),
        v.Button("Secondary")
    ])
)

Released under the MIT License.