Compose Unstyled 2.0 is out! Check the official announcement blog ->
Function

state

A helper function to implement state reading extension functions such as StyleScope.pressed for use with Boolean states.

state

Source set: Common
@ExperimentalFoundationStyleApi
fun StyleStateScope.state(key: StyleStateKey<Boolean>, block: () -> Unit) =
    state(key, block) { key, state -> state[key] }

A helper function to implement state reading extension functions such as StyleScope.pressed for use with Boolean states.

Custom style states can use this function to implement start reading functions to be consistent with the predefined state reading functions.

Parameters

key the StyleStateKey for the custom state.
block the block to execute when the style state is true.

Last updated: