Class

MutableStyleState

The state a style that can be updated to reflect the current state of a component.

Common
@ExperimentalFoundationStyleApi
class MutableStyleState
@RememberInComposition
constructor(override val interactionSource: InteractionSource?) : StyleState()

The state a style that can be updated to reflect the current state of a component. This value should be created in a component and updated to select the style parameter to be set for the component.

A component that uses an interaction source can create a MutableStyleState that observes the interactions emitted to the interaction source.

Functions

set

operator fun <T> set(key: StyleStateKey<T>, value: T)

Set the value of the key in the StyleState.


remove

fun <T> remove(key: StyleStateKey<T>)

Removes the StyleStateKey from the StyleState.

A Style will read the StyleStateKey.defaultValue for the StyleStateKey when the key is not present in the StyleState.

Removing a key that is updated via an InteractionSource will no longer observe the interaction source.

Predefined style keys, such as StyleStateKey.Pressed and StyleStateKey.Hovered, cannot be removed from the set of keys and this will throw if removed.