androidx.compose.foundation.style

Interfaces

Style

Style represents an opaque type which encodes a description of how to style a node in compose.

Cmn
StyleScope

A StyleScope is the receiver scope of a Style lambda.

Cmn

Classes

MutableStyleState

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

Cmn
StyleState

The state a style can use to select property values depending on the state of the component is a style for.

Cmn
StyleStateKey

The key to a StyleState value.

Cmn

Objects

Annotations

Top-level functions summary

Style

Combine multiple Style objects together.

Cmn
Style

Combine multiple Style objects together.

Cmn
Style
@ExperimentalFoundationStyleApi
Style(style1: Style, style2: Style, style3: Style)

Combine multiple Style objects together.

Cmn

Extension functions summary

Unit

Apply style to the current StyleScope.

Cmn
Unit

Defines a Style to be applied when the component is StyleState.isChecked is true.

Cmn
Unit

Defines a Style to be applied when the component is disabled.

Cmn
Unit

Sets the height of the component to fill the parent's available height (equivalent to height(1.0f)).

Cmn
Unit

Sets the width and height of the component to fill the parent's available space (equivalent to width(1.0f) and height(1.0f)).

Cmn
Unit

Sets the width of the component to fill the parent's available width (equivalent to width(1.0f)).

Cmn
Unit

Defines a Style to be applied when the component is focused.

Cmn
Unit

Defines a Style to be applied when the component is hovered.

Cmn
Unit

Defines a Style to be applied when the component is pressed.

Cmn
Unit

Defines a Style to be applied when the component is StyleState.isSelected is true.

Cmn
Modifier

This function is deprecated. The styleable() modifier must provide one or more 'style' parameter values.

Cmn
Modifier

Modifier that creates a region that is styled by the given Style object for the component this Modifier is attached to.

Cmn
Modifier

Modifier that creates a region that is styled by the given Style object for the component this Modifier is attached to.

Cmn
infix Style

Merges this styles with another.

Cmn
Unit

Defines a Style to be applied when the component is StyleState.triStateToggle is ToggleableState.Indeterminate.

Cmn
Unit

Defines a Style to be applied when the component is StyleState.triStateToggle is ToggleableState.Off.

Cmn
Unit

Defines a Style to be applied when the component is StyleState.triStateToggle is ToggleableState.On.

Cmn

Top-level functions

@ExperimentalFoundationStyleApi
fun Style(vararg styles: Style): Style

Combine multiple Style objects together. Styles whose argument positions are further "to the right" will override styles to the left of them, on a per-property basis.

@ExperimentalFoundationStyleApi
fun Style(style1: Style, style2: Style): Style

Combine multiple Style objects together. Styles whose argument positions are further "to the right" will override styles to the left of them, on a per-property basis.

@ExperimentalFoundationStyleApi
fun Style(style1: Style, style2: Style, style3: Style): Style

Combine multiple Style objects together. Styles whose argument positions are further "to the right" will override styles to the left of them, on a per-property basis.

Extension functions

@ExperimentalFoundationStyleApi
fun StyleScope.apply(style: Style): Unit

Apply style to the current StyleScope. Applying the scope calls the scope applies any properties set in the scope directly.

Parameters
style: Style

the style to apply.

@ExperimentalFoundationStyleApi
fun StyleScope.checked(value: Style): Unit

Defines a Style to be applied when the component is StyleState.isChecked is true. The properties within the provided value Style will override or merge with the base style of the component when a toggle interaction is detected.

@ExperimentalFoundationStyleApi
fun StyleScope.disabled(value: Style): Unit

Defines a Style to be applied when the component is disabled. The properties within the provided value Style will override or merge with the base style of the component when the style state for the component is disabled.

Parameters
value: Style

The Style to apply on hover.

See also
isEnabled
@ExperimentalFoundationStyleApi
fun StyleScope.fillHeight(): Unit

Sets the height of the component to fill the parent's available height (equivalent to height(1.0f)). The specified height includes any padding.

This property is not inherited

@ExperimentalFoundationStyleApi
fun StyleScope.fillSize(): Unit

Sets the width and height of the component to fill the parent's available space (equivalent to width(1.0f) and height(1.0f)). The specified size includes any padding.

This property is not inherited

@ExperimentalFoundationStyleApi
fun StyleScope.fillWidth(): Unit

Sets the width of the component to fill the parent's available width (equivalent to width(1.0f)). The specified width includes any padding.

This property is not inherited

@ExperimentalFoundationStyleApi
fun StyleScope.focused(value: Style): Unit

Defines a Style to be applied when the component is focused. The properties within the provided value Style will override or merge with the base style of the component when a focus interaction is detected.

Parameters
value: Style

The Style to apply on focus.

@ExperimentalFoundationStyleApi
fun StyleScope.hovered(value: Style): Unit

Defines a Style to be applied when the component is hovered. The properties within the provided value Style will override or merge with the base style of the component when a hover interaction is detected.

Parameters
value: Style

The Style to apply on hover.

@ExperimentalFoundationStyleApi
fun StyleScope.pressed(value: Style): Unit

Defines a Style to be applied when the component is pressed. The properties within the provided value Style will override or merge with the base style of the component when a press interaction is detected.

Parameters
value: Style

The Style to apply on press.

@ExperimentalFoundationStyleApi
fun StyleScope.selected(value: Style): Unit

Defines a Style to be applied when the component is StyleState.isSelected is true. The properties within the provided value Style will override or merge with the base style of the component when a toggle interaction is detected.

See also
isSelected

styleable

@ExperimentalFoundationStyleApi
fun Modifier.styleable(styleState: StyleState?): Modifier

Modifier that creates a region that is styled by the given Style object for the component this Modifier is attached to. Styles that are further "to the right", will have the properties they set override set properties of Styles to the left of them.

Apply styleable to creates a "styleable" component whose looks can be customized using the provided style together with one or more default Style objects. This should be called by a component that wishes to make itself styleable via a style: Style = Style parameter. If a component already takes a Style parameter, then that component internally is applying the styleable, and that Style parameter should be used instead of applying styleable again,

If styleable is added to a modifier chain that is after a another styleable, then the second region will wrap around the first. For example, if the two regions both supply padding then the padding will the sum of both regions.

Parameters
styleState: StyleState?

the state the style will use to decide which styles should be applied. If null is supplied, the style will only see the default state that will never be changed.

@ExperimentalFoundationStyleApi
fun Modifier.styleable(styleState: StyleState? = null, style: Style): Modifier

Modifier that creates a region that is styled by the given Style object for the component this Modifier is attached to.

Apply styleable to creates a "styleable" component whose looks can be customized using the provided style. This should be called by a component that wishes to make itself styleable via a style: Style = Style parameter. If a component already takes a Style parameter, then that component internally is applying the styleable, and that Style parameter should be used instead of applying styleable again.

If styleable is added to a modifier chain that is after a another styleable, then the second region will wrap around the first. For example, if the two regions both supply padding then the padding will the sum of both regions.

Parameters
styleState: StyleState? = null

the state the style will use to decide which styles should be applied. If null is supplied, the style will only see the default state that will never be changed.

style: Style

the style to apply to the styleable region.

@ExperimentalFoundationStyleApi
fun Modifier.styleable(styleState: StyleState?, vararg styles: Style): Modifier

Modifier that creates a region that is styled by the given Style object for the component this Modifier is attached to. Styles that are further "to the right", will have the properties they set override set properties of Styles to the left of them.

Apply styleable to creates a "styleable" component whose looks can be customized using the provided style together with one or more default Style objects. This should be called by a component that wishes to make itself styleable via a style: Style = Style parameter. If a component already takes a Style parameter, then that component internally is applying the styleable, and that Style parameter should be used instead of applying styleable again,

If styleable is added to a modifier chain that is after a another styleable, then the second region will wrap around the first. For example, if the two regions both supply padding then the padding will the sum of both regions.

Parameters
styleState: StyleState?

the state the style will use to decide which styles should be applied. If null is supplied, the style will only see the default state that will never be changed.

vararg styles: Style

the styles to apply, in order, to the stylable region.

@ExperimentalFoundationStyleApi
infix fun Style.then(other: Style): Style

Merges this styles with another. The style to the right on the then will overwrite the properties set by the style to the left.

Parameters
other: Style

the style to merge into the receiver.

triStateToggleIndeterminate

@ExperimentalFoundationStyleApi
fun StyleScope.triStateToggleIndeterminate(value: Style): Unit

Defines a Style to be applied when the component is StyleState.triStateToggle is ToggleableState.Indeterminate. The properties within the provided value Style will override or merge with the base style of the component when a toggle interaction is detected.

triStateToggleOff

@ExperimentalFoundationStyleApi
fun StyleScope.triStateToggleOff(value: Style): Unit

Defines a Style to be applied when the component is StyleState.triStateToggle is ToggleableState.Off. The properties within the provided value Style will override or merge with the base style of the component when a toggle interaction is detected.

triStateToggleOn

@ExperimentalFoundationStyleApi
fun StyleScope.triStateToggleOn(value: Style): Unit

Defines a Style to be applied when the component is StyleState.triStateToggle is ToggleableState.On. The properties within the provided value Style will override or merge with the base style of the component when a toggle interaction is detected.