Source set: Common
@ExperimentalFoundationStyleApi
interface StyleStateScope
An interface that introduces the state property to a Style receiver scope.
Properties
state
Source set: Common
val state: StyleState
The state of the component. applying this style. For example, if a component is pressed the StyleState.isPressed will be true.
Custom states can be read from the state using the StyleStateKey for the state.
Functions
state
fun <T> state(
key: StyleStateKey<T>,
block: () -> Unit,
active: (key: StyleStateKey<T>, state: StyleState) -> Boolean,
)
A helper function to implement state reading extension functions such as StyleScope.pressed.
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 active returns true. |
| active | an expression that should return true when the state is active and block should be called. |