Skip to content

TabContainer

@Composable



fun TabContainer(
    tabs: List<TabSpec>, 
    state: TabContainerState = rememberTabContainerState(tabs), 
    modifier: Modifier = Modifier, 
    onTabSelected: (TabSpec) -> Unit = {}, 
    tabSpacing: Int = 2, 
    scrollable: Boolean = true, 
    scrollState: ScrollableState? = null, 
    contentSpacing: Int = DEFAULT_CONTENT_SPACING, 
    elevateSelected: Boolean = false, 
    tabTexture: String = TabTextures.GAME
)

Declarative tab bar modeled after the vanilla Create World screen tabs.

Parameters

  • tabs: Ordered list of tab specs to render.

  • state: External state holder controlling the selected tab.

  • modifier: Modifier applied to the outer container (or scrollable wrapper).

  • onTabSelected: Callback invoked after a tab becomes selected.

  • tabSpacing: Horizontal spacing between neighboring tabs, in pixels.

  • scrollable: When true, wraps the tab row in a horizontal Scrollable viewport.

  • scrollState: Optional externally managed ScrollableState (only used when scrollable).

  • contentSpacing: Vertical spacing between the tab row and the selected tab content, in pixels.

@Composable



fun TabContainer(
    modifier: Modifier = Modifier, 
    state: TabContainerState? = null, 
    onTabSelected: (TabSpec) -> Unit = {}, 
    tabSpacing: Int = 2, 
    scrollable: Boolean = true, 
    scrollState: ScrollableState? = null, 
    contentSpacing: Int = DEFAULT_CONTENT_SPACING, 
    contentWrapper: @Composable



 (@Composable



 () -> Unit) -> Unit? = null, 
    tabTexture: String = TabTextures.GAME, 
    builder: TabContainerScope.() -> Unit
)

DSL overload allowing tabs to be declared inline via TabContainerScope.tab without manually building a TabSpec list.

Parameters

  • contentWrapper: Wraps each tab's content composable, e.g. to add common padding. Defaults to rendering the content unwrapped.

  • builder: Declares the tabs, in order, via TabContainerScope.tab.