tab

package
v0.1.67 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 14 Imported by: 0

README

Tab

We need the Conatiner and Content Color. The colorReader need to be propagated to the runtime

Theme Colors from the ourside are constants - just strings to be realized at runtime

TabRow

Replaced with PrimaryTabRow and SecondaryTabRow.

@Composable
fun TabRow(
    selectedTabIndex: Int,
    modifier: Modifier = Modifier,
    containerColor: Color = TabRowDefaults.primaryContainerColor,
    contentColor: Color = TabRowDefaults.primaryContentColor,
    indicator: @Composable (tabPositions: List<TabPosition>) -> Unit = @Composable { tabPositions ->
            if (selectedTabIndex < tabPositions.size) {
                TabRowDefaults.SecondaryIndicator(
                    Modifier.tabIndicatorOffset(tabPositions[selectedTabIndex])
                )
            }
        },
    divider: @Composable () -> Unit = @Composable { HorizontalDivider() },
    tabs: @Composable () -> Unit
): Unit

Tab

@Composable
fun Tab(
    selected: Boolean,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    selectedContentColor: Color = LocalContentColor.current,
    unselectedContentColor: Color = selectedContentColor,
    interactionSource: MutableInteractionSource? = null,
    content: @Composable ColumnScope.() -> Unit
): Unit

@Composable
fun Tab(
    selected: Boolean,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    text: (@Composable () -> Unit)? = null,
    icon: (@Composable () -> Unit)? = null,
    selectedContentColor: Color = LocalContentColor.current,
    unselectedContentColor: Color = selectedContentColor,
    interactionSource: MutableInteractionSource? = null
): Unit

PrimaryTabRow

@Composable
fun PrimaryTabRow(
    selectedTabIndex: Int,
    modifier: Modifier = Modifier,
    containerColor: Color = TabRowDefaults.primaryContainerColor,
    contentColor: Color = TabRowDefaults.primaryContentColor,
    indicator: @Composable TabIndicatorScope.() -> Unit = {
        TabRowDefaults.PrimaryIndicator(
            modifier = Modifier.tabIndicatorOffset(selectedTabIndex, matchContentSize = true),
            width = Dp.Unspecified,
        )
    },
    divider: @Composable () -> Unit = @Composable { HorizontalDivider() },
    tabs: @Composable () -> Unit
): Unit

SecondaryTabRow

@Composable
fun SecondaryTabRow(
    selectedTabIndex: Int,
    modifier: Modifier = Modifier,
    containerColor: Color = TabRowDefaults.secondaryContainerColor,
    contentColor: Color = TabRowDefaults.secondaryContentColor,
    indicator: @Composable TabIndicatorScope.() -> Unit = @Composable {
            TabRowDefaults.SecondaryIndicator(
                Modifier.tabIndicatorOffset(selectedTabIndex, matchContentSize = false)
            )
        },
    divider: @Composable () -> Unit = @Composable { HorizontalDivider() },
    tabs: @Composable () -> Unit
): Unit

Documentation

Overview

Package tab contains Material 3 Tab components.

Reference: [Tabs](https://m3.material.io/components/tabs/overview) Specs: [Tabs Specs](https://m3.material.io/components/tabs/specs)

Index

Constants

This section is empty.

Variables

View Source
var TabDefaults = tabDefaults{}
View Source
var TabRowDefaults = tabRowDefaults{}

TabRowDefaults holds default values for the TabRow and Tab components.

Functions

This section is empty.

Types

type Composable

type Composable = api.Composable

func Tab

func Tab(
	selected bool,
	onClick func(),
	content Composable,
	options ...TabOption,
) Composable

Tab is a single tab in a TabRow.

func TabRow

func TabRow(
	selectedTabIndex int,
	content Composable,
	options ...TabRowOption,
) Composable

TabRow contains a row of Tabs and displays an indicator underneath the currently selected Tab.

type Composer

type Composer = api.Composer

type TabOption

type TabOption func(options *TabOptions)

func WithModifier

func WithModifier(m ui.Modifier) TabOption

type TabOptions

type TabOptions struct {
	Modifier               ui.Modifier
	Selected               bool
	OnClick                func()
	Enabled                bool
	SelectedContentColor   graphics.Color
	UnselectedContentColor graphics.Color
}

TabOptions holds the configuration for Tab.

func DefaultTabOptions

func DefaultTabOptions(c Composer) TabOptions

DefaultTabOptions returns the default options for Tab.

type TabRowOption

type TabRowOption func(options *TabRowOptions)

func WithTabRowModifier

func WithTabRowModifier(modifier ui.Modifier) TabRowOption

type TabRowOptions

type TabRowOptions struct {
	Modifier       ui.Modifier
	ContainerColor graphics.Color
	ContentColor   graphics.Color
	Indicator      Composable
}

TabRowOptions holds the configuration for TabRow.

func DefaultTabRowOptions

func DefaultTabRowOptions() TabRowOptions

DefaultTabRowOptions returns the default options for TabRow.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL