ContentSwitcher

fun ContentSwitcher(options: List<String>, selectedOption: String, onOptionSelected: (String) -> Unit, modifier: Modifier = Modifier, size: ContentSwitcherSize = ContentSwitcherSize.Medium, isEnabled: Boolean = true)

Content switcher

Content switchers allow users to toggle between two or more content sections within the same space on the screen.

Content switchers are frequently used to let users toggle between different formattings, like a grid view and a table view. They are also often used to narrow large content groups or to sort related content. For example, a messaging tool may use a content switcher to divide messages into three views such as “All,” “Read,” and “Unread.”

(From Content switcher documentation)

Parameters

options

A list of strings representing the options to be displayed. Each string is a label for an option. At least two options are required, otherwise, an IllegalArgumentException will be thrown.

selectedOption

The currently selected option.

onOptionSelected

Callback invoked when an option is selected. The label of the selected option is passed as a parameter.

modifier

The modifier to be applied to the content switcher.

size

The ContentSwitcherSize to be applied to the content switcher. Defaults to ContentSwitcherSize.Medium.

isEnabled

Whether the content switcher is enabled or disabled.