Skip to content

TabControl

extends Container

TabControl: header row of tab titles, one content container per tab. addTab(title) returns the tab's container; fires "change" on switch.

Properties

PropertyTypeDefaultDescription
activeinteger0Index of the active tab; switching updates the tab containers' visibility
headerBackgroundnumbercolors.grayinactive header row
activeBackgroundnumbercolors.blueactive tab title
activeForegroundnumbercolors.whiteText color of the active tab title
backgroundnumber|falsecolors.blackBackground color (false = transparent)
widthnumber24Width in terminal cells
heightnumber10Height in terminal cells

Events

EventRegistrarDescription
change:onChange(fn)Fired after a tab switch with (index, title)

Methods

TabControl:setup()

Initializes per-instance state and input handlers.

TabControl:addTab(title)

Adds a tab and returns its content container (fills the area below the header). The first tab becomes active automatically.

  • title (string) The tab title shown in the header

  • returns tab (Frame) The tab's content container

lua
local settings = tc:addTab("Settings")

TabControl:setActiveTab(index, emit)

Switches to a tab and fires the change event.

  • index (integer) The tab index

  • emit (boolean, optional) false suppresses the change event

  • returns (self)

TabControl:getTab(index)

Returns a tab's content container.

  • index (integer) The tab index

  • returns tab (Frame|nil) The tab container, or nil

TabControl:getTabCount()

Returns the number of registered tabs.

  • returns count (integer)

TabControl:handleKey(event, a, b)

Handles keyboard input while focused.

  • event (string) The key event name (key, key_up, char, paste)
  • a (any) Key code or typed text
  • b (any, optional) Secondary key-event value

TabControl:render(buf)

Renders the element into the buffer.

  • buf (Render) The render buffer (local coordinates, pre-clipped)

Last updated:

Released under the MIT License.