Skip to content

TabContainerState

@Stable



class TabContainerState

Tracks which tab id is selected in a TabContainer. Create via rememberTabContainerState.

Properties

selectedTabId

The currently selected tab's id, or null if nothing is selected yet.

Functions

ensureSelection

Ensures the selection is valid for tabs: falls back to the first enabled tab (or the very first tab, if none are enabled) when there's no selection or the selected id no longer exists/is disabled among tabs.

isSelected

fun isSelected(tabId: String): Boolean

Whether tabId is the currently selected tab.

select

fun select(tabId: String)

Selects the tab with the given tabId.

selectedIndex

fun selectedIndex(tabs: List<TabSpec>): Int

The index of the selected tab within tabs, or -1 if none is selected.

selectedTab

The TabSpec currently selected within tabs, or null if none is selected.