ConsoleForge 0.3.0
Elm-architecture TUI framework for .NET 8
Loading...
Searching...
No Matches
ConsoleForge.Widgets.Tabs Class Referencesealed

A tabbed navigation widget. More...

Inheritance diagram for ConsoleForge.Widgets.Tabs:

Public Member Functions

void OnKeyEvent (KeyMsg key, Action< IMsg > dispatch)
 Left/Right arrows cycle tabs.
void Render (IRenderContext ctx)
 Renders the tab bar on row 0 of the allocated region, then delegates Body into the remaining rows.
 Tabs ()
 Object-initializer constructor; all properties default.
 Tabs (IReadOnlyList< string > labels, int activeIndex=0, IWidget? body=null, Style? style=null, Style? activeTabStyle=null, Style? inactiveTabStyle=null)
 Positional constructor for inline usage.

Properties

int ActiveIndex [get]
 Zero-based index of the currently active tab.
Style ActiveTabStyle = Style.Default.Bold(true).Underline(true) [get]
 Style applied to the active tab label.
IWidgetBody [get]
 Content widget to render below the tab bar.
bool HasFocus [get, set]
 True when this widget holds keyboard focus.
SizeConstraint Height = SizeConstraint.Flex(1) [get]
 Height constraint used by the layout engine.
Style InactiveTabStyle = Style.Default [get]
 Style applied to inactive tab labels.
IReadOnlyList< string > Labels = [] [get]
 Tab label strings in declaration order.
char Separator = '│' [get]
 Character used to separate tab labels in the bar.
Style Style = Style.Default [get]
 Visual style for the tab bar row. Inherits theme base style when unset.
SizeConstraint Width = SizeConstraint.Flex(1) [get]
 Width constraint used by the layout engine.

Detailed Description

A tabbed navigation widget.

Renders a tab bar on the first row, and the Body widget in the remaining area.

The caller is responsible for supplying the correct Body for the ActiveIndex (swap it in the model's Update handler when TabChangedMsg arrives).

Key handling when focused:

  • Left/Right arrows — cycle tabs, wrap-around.
  • Number keys 1–9 — jump directly to tab N-1.

Tab switching does not move keyboard focus to the body — the model controls focus assignment independently.

Constructor & Destructor Documentation

◆ Tabs()

ConsoleForge.Widgets.Tabs.Tabs ( IReadOnlyList< string > labels,
int activeIndex = 0,
IWidget? body = null,
Style? style = null,
Style? activeTabStyle = null,
Style? inactiveTabStyle = null )

Positional constructor for inline usage.

Parameters
labelsTab label strings.
activeIndexInitially active tab (clamped to valid range).
bodyContent widget for the active tab.
styleOptional tab bar style override.
activeTabStyleOptional style for the active tab label.
inactiveTabStyleOptional style for inactive tab labels.

Member Function Documentation

◆ OnKeyEvent()

void ConsoleForge.Widgets.Tabs.OnKeyEvent ( KeyMsg key,
Action< IMsg > dispatch )

Left/Right arrows cycle tabs.

Number keys 1–9 jump to a specific tab.

Implements ConsoleForge.Layout.IFocusable.

Property Documentation

◆ Body

IWidget? ConsoleForge.Widgets.Tabs.Body
get

Content widget to render below the tab bar.

Typically the widget associated with ActiveIndex. May be null (only the tab bar is drawn).

◆ Separator

char ConsoleForge.Widgets.Tabs.Separator = '│'
get

Character used to separate tab labels in the bar.

Default '│'. Set to '\0' to disable separators.


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