A StyleScope is the receiver scope of a Style lambda. It allows defining the properties of a style that will be used by a styleable modifier to allow customizing the look of a composable component in its default state and in states like hover, pressed, or focused readable from the state property.

The properties set on a style scope affect the styled region of a component. A component creates a styled region by using the styleable modifier.

See also
Style

Summary

Public functions

Unit
alpha(value: @FloatRange(from = 0.0, to = 1.0) Float)

Sets the opacity of the component.

Cmn
Unit
animate(value: Style)

Specifies a Style whose properties will be animated to when they change.

Cmn
Unit
animate(spec: AnimationSpec<Float>, value: Style)

Specifies a Style whose properties will be animated to when they change, using the provided AnimationSpec.

Cmn
Unit
animate(
    toSpec: AnimationSpec<Float>,
    fromSpec: AnimationSpec<Float>,
    value: Style
)

Specifies a Style whose properties will be animated to when they change, using the provided AnimationSpec.

Cmn
Unit
background(color: Color)

Sets the background color of the component.

Cmn
Unit
background(value: Brush)

Sets the background of the component using a Brush.

Cmn
Unit

Sets the baseline shift for the text (e.g., for superscript or subscript).

Cmn
Unit
border(width: Dp, brush: Brush)

Sets a border for the component with the specified width and brush.

Cmn
Unit
border(width: Dp, color: Color)

Sets a solid border for the component with the specified width and color.

Cmn
Unit

Sets the brush used to paint the border around the component.

Cmn
Unit

Sets the color of the border around the component.

Cmn
Unit
borderWidth(value: Dp)

Sets the width of the border around the component.

Cmn
Unit
bottom(value: Dp)

Offsets the component vertically from its original calculated bottom position.

Cmn
Unit
clip(value: Boolean)

Clips the component to its bounds.

Cmn
Unit

Sets the preferred brush for rendering content, primarily affecting text.

Cmn
Unit

Sets the preferred content color, primarily affecting text color.

Cmn
Unit

Sets the padding for all four edges (top, end, bottom, start) edges of the component's content.

Cmn
Unit
contentPadding(horizontal: Dp, vertical: Dp)

Sets the padding for the vertical (top and bottom) and horizontal (start and end) edges of the component's content.

Cmn
Unit
contentPadding(start: Dp, top: Dp, end: Dp, bottom: Dp)

Sets the padding for all four edges (top, end, bottom, start) edges of the component's content.

Cmn
Unit

Sets the padding for the bottom edge of the component's content.

Cmn
Unit

Sets the padding for the end edge of the component's content.

Cmn
Unit

Sets the padding for the horizontal (start and end) edges of the component's content.

Cmn
Unit

Sets the padding for the start edge of the component's content.

Cmn
Unit

Sets the padding for the top edge of the component's content.

Cmn
Unit

Sets the padding for the vertical (start and end) edges of the component's content.

Cmn
Unit

Applies a drop shadow effect directly to the component, often used for text or specific graphics.

Cmn
Unit
dropShadow(vararg value: Shadow)

Applies one or more drop shadow effects directly to the component.

Cmn
Unit

Sets the external padding for all four edges (top, end, bottom, start) of the component.

Cmn
Unit
externalPadding(horizontal: Dp, vertical: Dp)

Sets the external padding for the vertical (top and bottom) and horizontal (start and end) edges of the component.

Cmn
Unit
externalPadding(start: Dp, top: Dp, end: Dp, bottom: Dp)

Sets the external padding for all four edges (top, end, bottom, start) of the component.

Cmn
Unit

Sets the external padding for the bottom edge of the component.

Cmn
Unit

Sets the external padding for the end edge of the component.

Cmn
Unit

Sets the external padding for the horizontal (start and end) edges of the component.

Cmn
Unit

Sets the external padding for the start edge of the component.

Cmn
Unit

Sets the external padding for the top edge of the component.

Cmn
Unit

Sets the external padding for the vertical (start and end) edges of the component.

Cmn
Unit

Sets the font family for the text.

Cmn
Unit

Sets the font size for the text.

Cmn
Unit

Sets the font style for the text (e.g., italic, normal).

Cmn
Unit

Sets the font synthesis strategy, determining if and how bold/italic styles are synthesized when the font family does not natively support them.

Cmn
Unit

Sets the font weight for the text (e.g., bold, normal).

Cmn
Unit
foreground(value: Brush)

Sets the foreground brush for the component.

Cmn
Unit
foreground(value: Color)

Sets the foreground color for the component.

Cmn
Unit
height(fraction: @FloatRange(from = 0.0, to = 1.0) Float)

Sets the height of the component to a fraction of the parent's available height.

Cmn
Unit
height(value: Dp)

Sets the preferred height of the component.

Cmn
Unit
hyphens(value: Hyphens)

Sets the hyphenation strategy for text.

Cmn
Unit

Applies an inner shadow effect to the component.

Cmn
Unit
innerShadow(vararg value: Shadow)

Applies one or more inner shadow effects to the component.

Cmn
Unit
left(value: Dp)

Offsets the component horizontally from its original calculated left position.

Cmn
Unit

Sets the letter spacing for the text.

Cmn
Unit

Sets the line breaking strategy for text.

Cmn
Unit

Sets the line height for the text.

Cmn
Unit
maxHeight(value: Dp)

Constrains the maximum height of the component.

Cmn
Unit
maxSize(size: DpSize)

Constrains the maximum size (width and height) of the component.

Cmn
Unit
maxSize(width: Dp, height: Dp)

Constrains the maximum width and height of the component.

Cmn
Unit
maxWidth(value: Dp)

Constrains the maximum width of the component.

Cmn
Unit
minHeight(value: Dp)

Constrains the minimum height of the component.

Cmn
Unit
minSize(size: DpSize)

Constrains the minimum size (width and height) of the component.

Cmn
Unit
minSize(width: Dp, height: Dp)

Constrains the minimum width and height of the component.

Cmn
Unit
minWidth(value: Dp)

Constrains the minimum width of the component.

Cmn
Unit
right(value: Dp)

Offsets the component horizontally from its original calculated right position.

Cmn
Unit
rotationX(value: Float)

Rotates the component around the X-axis through its center.

Cmn
Unit
rotationY(value: Float)

Rotates the component around the Y-axis through its center.

Cmn
Unit
rotationZ(value: Float)

Rotates the component around the Z-axis (perpendicular to the screen) through its center.

Cmn
Unit
scale(value: @FloatRange(from = 0.0) Float)

Scales the component uniformly (both horizontally and vertically) around its center pivot point.

Cmn
Unit
scaleX(value: @FloatRange(from = 0.0) Float)

Scales the component horizontally around its center pivot point.

Cmn
Unit
scaleY(value: @FloatRange(from = 0.0) Float)

Scales the component vertically around its center pivot point.

Cmn
Unit
shape(value: Shape)

Sets the Shape for the component.

Cmn
Unit
size(value: Dp)

Sets the preferred width and height of the component to the same value.

Cmn
Unit
size(value: DpSize)

Sets the preferred width and height of the component using a DpSize object.

Cmn
Unit
size(width: Dp, height: Dp)

Sets the preferred width and height of the component.

Cmn
Unit
<T : Any?> state(
    key: StyleStateKey<T>,
    value: Style,
    active: (key: StyleStateKey<T>, state: StyleState) -> Boolean
)

A helper function to implement state reading extension functions such as StyleScope.pressed.

Cmn
Unit

Sets the text alignment (e.g., start, end, center).

Cmn
Unit

Sets the text decoration (e.g., underline, line-through).

Cmn
Unit

Sets the text direction (e.g., LTR, RTL, content-based).

Cmn
Unit

Sets the text indent (e.g., for the first line or subsequent lines).

Cmn
Unit

Applies a complete TextStyle object to the component.

Cmn
Unit
top(value: Dp)

Offsets the component vertically from its original calculated top position.

Cmn
Unit

Offset percentage along the x and y axis for which contents are rotated and scaled.

Cmn
Unit

Translates (moves) the component by the given Offset.

Cmn
Unit
translation(x: @FloatRange(from = 0.0) Float, y: @FloatRange(from = 0.0) Float)

Translates (moves) the component horizontally and vertically.

Cmn
Unit
translationX(value: @FloatRange(from = 0.0) Float)

Translates (moves) the component horizontally.

Cmn
Unit
translationY(value: @FloatRange(from = 0.0) Float)

Translates (moves) the component vertically.

Cmn
Unit
width(fraction: @FloatRange(from = 0.0, to = 1.0) Float)

Sets the width of the component to a fraction of the parent's available width.

Cmn
Unit
width(value: Dp)

Sets the preferred width of the component.

Cmn
Unit
zIndex(value: @FloatRange(from = 0.0) Float)

Sets the Z-index of the component.

Cmn

Public properties

StyleState

The state of the component. applying this style.

Cmn

Extension functions

Unit

Apply style to the current StyleScope.

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 StyleState.isChecked is true.

Cmn
Unit

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

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
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

Inherited functions

From androidx.compose.ui.unit.Density
open Int

Convert Dp to Int by rounding

Cmn
open Int

Convert Sp to Int by rounding

Cmn
open Dp

Convert an Int pixel value to Dp.

Cmn
open Dp

Convert a Float pixel value to a Dp

Cmn
open DpSize

Convert a Size to a DpSize.

Cmn
open Float

Convert Dp to pixels.

Cmn
open Float

Convert Sp to pixels.

Cmn
open Rect

Convert a DpRect to a Rect.

Cmn
open Size

Convert a DpSize to a Size.

Cmn
open TextUnit

Convert an Int pixel value to Sp.

Cmn
open TextUnit

Convert a Float pixel value to a Sp

Cmn
From androidx.compose.ui.unit.FontScaling
Dp

Convert Sp to Dp.

Cmn
TextUnit

Convert Dp to Sp.

Cmn

Inherited properties

From androidx.compose.runtime.CompositionLocalAccessorScope
T

An extension property that allows accessing the current value of a composition local in the context of this scope.

Cmn
From androidx.compose.ui.unit.Density
Float

The logical density of the display.

Cmn
From androidx.compose.ui.unit.FontScaling
Float

Current user preference for the scaling factor for fonts.

Cmn

Public functions

alpha

fun alpha(value: @FloatRange(from = 0.0, to = 1.0) Float): Unit

Sets the opacity of the component. A value of 1.0f means fully opaque, 0.0f means fully transparent.

This property is not inherited

Parameters
value: @FloatRange(from = 0.0, to = 1.0) Float

The alpha value (0.0f to 1.0f).

See also
alpha
graphicsLayer

animate

fun animate(value: Style): Unit

Specifies a Style whose properties will be animated to when they change. This uses a default animation specification. This allows for smooth transitions between style states without manual animation setup. A androidx.compose.animation.core.spring will be used for the animation for both animating to and from the style.

Parameters
value: Style

The target Style whose properties should be animated.

See also
Style

animate

fun animate(spec: AnimationSpec<Float>, value: Style): Unit

Specifies a Style whose properties will be animated to when they change, using the provided AnimationSpec. This allows for smooth transitions between style states with custom animation curves. The same animation spec will be used for animating both to and from the style.

Parameters
spec: AnimationSpec<Float>

The AnimationSpec to use for the animation.

value: Style

The target Style whose properties should be animated.

See also
Style
AnimationSpec

animate

fun animate(
    toSpec: AnimationSpec<Float>,
    fromSpec: AnimationSpec<Float>,
    value: Style
): Unit

Specifies a Style whose properties will be animated to when they change, using the provided AnimationSpec. This allows for smooth transitions between style states with custom animation curves.

Parameters
toSpec: AnimationSpec<Float>

The AnimationSpec to use for the animation to the values set in value. This animation is used when the animate call is added to the style.

fromSpec: AnimationSpec<Float>

The AnimationSpec to use for the animation from the values set in value. This animation is used when the animate call is removed from the style.

value: Style

The target Style whose properties should be animated.

See also
Style
AnimationSpec

background

fun background(color: Color): Unit

Sets the background color of the component. If a shape is applied, the background will fill that shape.

Setting a background color will override any previously set background brush.

This property is not inherited

Parameters
color: Color

The background color.

See also
shape
background

background

fun background(value: Brush): Unit

Sets the background of the component using a Brush. This allows for gradient backgrounds or other complex fills. If a shape is applied, the background will fill that shape.

Setting a background brush will override any previously set background color.

This property is not inherited

Parameters
value: Brush

The brush to use for the background.

See also
shape
background

baselineShift

fun baselineShift(value: BaselineShift): Unit

Sets the baseline shift for the text (e.g., for superscript or subscript). This property is inherited by child text components if not overridden. This affects text layout and rendering, and is a component of a TextStyle.

This property is inherited.

Parameters
value: BaselineShift

The BaselineShift to apply.

See also
textStyle
TextStyle

border

fun border(width: Dp, brush: Brush): Unit

Sets a border for the component with the specified width and brush. The border is drawn on top of the background and the padded content. The border itself does not contribute to the component's layout size (width/height).

This property is not inherited

Parameters
width: Dp

The width of the border.

brush: Brush

The brush to paint the border (e.g., for gradients).

border

fun border(width: Dp, color: Color): Unit

Sets a solid border for the component with the specified width and color. The border is drawn on top of the background and the padded content. The border itself does not contribute to the component's layout size (width/height).

This property is not inherited

Parameters
width: Dp

The width of the border.

color: Color

The color of the border.

borderBrush

fun borderBrush(value: Brush): Unit

Sets the brush used to paint the border around the component. The border is drawn on top of the background and the padded content. This method only sets the brush; width must be set separately. The border's presence and appearance do not affect the component's layout size.

This property is not inherited

Parameters
value: Brush

The brush to paint the border (e.g., for gradients).

See also
borderWidth
borderColor
border

(Dp, Brush)

border

borderColor

fun borderColor(value: Color): Unit

Sets the color of the border around the component. The border is drawn on top of the background and the padded content. This method only sets the color; width must be set separately. The border's presence and appearance do not affect the component's layout size.

This property is not inherited

Parameters
value: Color

The color of the border.

borderWidth

fun borderWidth(value: Dp): Unit

Sets the width of the border around the component. The border is drawn on top of the background and the padded content. The border's width does not contribute to the component's layout size (width/height); it is rendered within the component's bounds This method only sets the width; color or brush must be set separately.

This property is not inherited

Parameters
value: Dp

The width of the border.

bottom

fun bottom(value: Dp): Unit

Offsets the component vertically from its original calculated bottom position. Positive values shift the component upwards (further from the bottom edge), negative downwards.

This property is not inherited

Parameters
value: Dp

The amount to offset from the bottom edge.

See also
left
top
right
offset

clip

fun clip(value: Boolean = true): Unit

Clips the component to its bounds. If a shape is also applied, it clips to the shape. When clip is true content that overflows the component's bounds is not drawn.

This property is not inherited

Parameters
value: Boolean = true

true to clip (default), false to allow drawing outside bounds.

contentBrush

fun contentBrush(value: Brush): Unit

Sets the preferred brush for rendering content, primarily affecting text. This allows for gradient text or other brush-based text effects. This property is inherited by child text components if not overridden. This affects drawing only and is often a component of a TextStyle.

This property is inherited.

Parameters
value: Brush

The brush for the content, typically text.

contentColor

fun contentColor(value: Color): Unit

Sets the preferred content color, primarily affecting text color. This property is inherited by child text components if not overridden. This affects drawing only and is often a component of a TextStyle.

This property is inherited.

Parameters
value: Color

The color for the content, typically text.

contentPadding

fun contentPadding(value: Dp): Unit

Sets the padding for all four edges (top, end, bottom, start) edges of the component's content. Content padding is the space between the component's border (if any) and its content. The width/height of the component includes content padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to all four edges.

contentPadding

fun contentPadding(horizontal: Dp, vertical: Dp): Unit

Sets the padding for the vertical (top and bottom) and horizontal (start and end) edges of the component's content. Content padding is the space between the component's border (if any) and its content. The width/height of the component includes content padding.

This property is not inherited

Parameters
horizontal: Dp

The padding for the start and end edges.

vertical: Dp

The padding for the top and bottom edges.

contentPadding

fun contentPadding(start: Dp, top: Dp, end: Dp, bottom: Dp): Unit

Sets the padding for all four edges (top, end, bottom, start) edges of the component's content. Content padding is the space between the component's border (if any) and its content. The width/height of the component includes content padding.

This property is not inherited

Parameters
start: Dp

The padding for the start edge.

top: Dp

The padding for the top edge.

end: Dp

The padding for the end edge.

bottom: Dp

The padding for the bottom edge.

contentPaddingBottom

fun contentPaddingBottom(value: Dp): Unit

Sets the padding for the bottom edge of the component's content. Content padding is the space between the component's border (if any) and its content. The width/height of the component includes content padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to the bottom edge.

contentPaddingEnd

fun contentPaddingEnd(value: Dp): Unit

Sets the padding for the end edge of the component's content. Content padding is the space between the component's border (if any) and its content. The width/height of the component includes content padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to the end edge.

contentPaddingHorizontal

fun contentPaddingHorizontal(value: Dp): Unit

Sets the padding for the horizontal (start and end) edges of the component's content. Content padding is the space between the component's border (if any) and its content. The width/height of the component includes content padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to both start and end edges.

contentPaddingStart

fun contentPaddingStart(value: Dp): Unit

Sets the padding for the start edge of the component's content. Content padding is the space between the component's border (if any) and its content. The width/height of the component includes content padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to the start edge.

contentPaddingTop

fun contentPaddingTop(value: Dp): Unit

Sets the padding for the top edge of the component's content. Content padding is the space between the component's border (if any) and its content. The width/height of the component includes content padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to the top edge.

contentPaddingVertical

fun contentPaddingVertical(value: Dp): Unit

Sets the padding for the vertical (start and end) edges of the component's content. Content padding is the space between the component's border (if any) and its content. The width/height of the component includes content padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to both top and bottom edges.

dropShadow

fun dropShadow(value: Shadow): Unit

Applies a drop shadow effect directly to the component, often used for text or specific graphics. This is distinct from shadowElevation which is specific to platform elevation shadows. Multiple drop shadows can be applied by calling this function multiple times or using the vararg overload. The border and overall layout size are not affected by this shadow.

If shape is set, the shadow will be applied to the shape's bounds.

This property is not inherited.

Parameters
value: Shadow

The Shadow properties (color, offset, blurRadius) for the drop shadow.

dropShadow

fun dropShadow(vararg value: Shadow): Unit

Applies one or more drop shadow effects directly to the component. This is distinct from shadowElevation. The border and overall layout size are not affected by these shadows.

This property is not inherited.

Parameters
vararg value: Shadow

A vararg of Shadow properties to apply as drop shadows.

externalPadding

fun externalPadding(value: Dp): Unit

Sets the external padding for all four edges (top, end, bottom, start) of the component. The external padding is the space between the edge of the component and its border (if any). The width/height of the component includes external padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to all four edges.

externalPadding

fun externalPadding(horizontal: Dp, vertical: Dp): Unit

Sets the external padding for the vertical (top and bottom) and horizontal (start and end) edges of the component. The external padding is the space between the edge of the component and its border (if any). The width/height of the component includes external padding.

This property is not inherited

Parameters
horizontal: Dp

The padding for the start and end edges.

vertical: Dp

The padding for the top and bottom edges.

externalPadding

fun externalPadding(start: Dp, top: Dp, end: Dp, bottom: Dp): Unit

Sets the external padding for all four edges (top, end, bottom, start) of the component. The external padding is the space between the edge of the component and its border (if any). The width/height of the component includes external padding.

This property is not inherited

Parameters
start: Dp

The padding for the start edge.

top: Dp

The padding for the top edge.

end: Dp

The padding for the end edge.

bottom: Dp

The padding for the bottom edge.

externalPaddingBottom

fun externalPaddingBottom(value: Dp): Unit

Sets the external padding for the bottom edge of the component. The external padding is the space between the edge of the component and its border (if any). The width/height of the component includes external padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to the bottom edge.

externalPaddingEnd

fun externalPaddingEnd(value: Dp): Unit

Sets the external padding for the end edge of the component. The external padding is the space between the edge of the component and its border (if any). The width/height of the component includes external padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to the end edge.

externalPaddingHorizontal

fun externalPaddingHorizontal(value: Dp): Unit

Sets the external padding for the horizontal (start and end) edges of the component. The external padding is the space between the edge of the component and its border (if any). The width/height of the component includes external padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to both start and end edges.

externalPaddingStart

fun externalPaddingStart(value: Dp): Unit

Sets the external padding for the start edge of the component. The external padding is the space between the edge of the component and its border (if any). The width/height of the component includes external padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to the start edge.

externalPaddingTop

fun externalPaddingTop(value: Dp): Unit

Sets the external padding for the top edge of the component. The external padding is the space between the edge of the component and its border (if any). The width/height of the component includes external padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to the top edge.

externalPaddingVertical

fun externalPaddingVertical(value: Dp): Unit

Sets the external padding for the vertical (start and end) edges of the component. The external padding is the space between the edge of the component and its border (if any). The width/height of the component includes external padding.

This property is not inherited

Parameters
value: Dp

The amount of padding to apply to both top and bottom edges.

fontFamily

fun fontFamily(value: FontFamily): Unit

Sets the font family for the text. This property is inherited by child text components if not overridden. This affects text layout and rendering, and is a component of a TextStyle.

This property is inherited.

Parameters
value: FontFamily

The FontFamily to use.

See also
textStyle
TextStyle

fontSize

fun fontSize(value: TextUnit): Unit

Sets the font size for the text. This property is inherited by child text components if not overridden. This affects text layout and rendering, and is a component of a TextStyle.

This property is inherited.

Parameters
value: TextUnit

The font size in TextUnit (e.g., 16.sp).

See also
textStyle
TextStyle

fontStyle

fun fontStyle(value: FontStyle): Unit

Sets the font style for the text (e.g., italic, normal). This property is inherited by child text components if not overridden. This affects text rendering and is a component of a TextStyle.

This property is inherited.

Parameters
value: FontStyle

The FontStyle to apply.

See also
textStyle
TextStyle

fontSynthesis

fun fontSynthesis(value: FontSynthesis): Unit

Sets the font synthesis strategy, determining if and how bold/italic styles are synthesized when the font family does not natively support them. This property is inherited by child text components if not overridden. This affects text rendering and is a component of a TextStyle.

This property is inherited.

Parameters
value: FontSynthesis

The FontSynthesis strategy to apply.

See also
textStyle
TextStyle

fontWeight

fun fontWeight(value: FontWeight): Unit

Sets the font weight for the text (e.g., bold, normal). This property is inherited by child text components if not overridden. This affects text rendering and is a component of a TextStyle.

This property is inherited.

Parameters
value: FontWeight

The FontWeight to apply.

See also
textStyle
TextStyle

foreground

fun foreground(value: Brush): Unit

Sets the foreground brush for the component. This can be used to overlay a color or gradient on top of the component's content. It is important that this brush be partially transparent (e.g. alpha less than 1.0) or it will obscure the content. If a shape is applied, the foreground will fill that shape.

This property is not inherited

Parameters
value: Brush

The brush to use for the foreground.

foreground

fun foreground(value: Color): Unit

Sets the foreground color for the component. This can be used to overlay a color on top of the component's content. It is important that this brush be partially transparent (e.g. alpha less than 1.0) or it will obscure the content. If a shape is applied, the foreground will fill that shape.

This property is not inherited

Parameters
value: Color

The brush to use for the foreground.

height

fun height(fraction: @FloatRange(from = 0.0, to = 1.0) Float): Unit

Sets the height of the component to a fraction of the parent's available height. The specified height includes any padding.

This property is not inherited

Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float

The fraction of the available height (e.g., 0.5f for 50%).

height

fun height(value: Dp): Unit

Sets the preferred height of the component. The actual size will also depend on the parent's constraints and other modifiers. The specified height includes both contentPadding and externalPadding.

This property is not inherited

Parameters
value: Dp

The preferred height in Dp.

hyphens

fun hyphens(value: Hyphens): Unit

Sets the hyphenation strategy for text. This property is inherited by child text components if not overridden. This affects text layout and is a component of a TextStyle.

This property is inherited.

Parameters
value: Hyphens

The Hyphens strategy to apply.

See also
textStyle
TextStyle

innerShadow

fun innerShadow(value: Shadow): Unit

Applies an inner shadow effect to the component. This shadow is drawn inside the bounds of the component. Multiple inner shadows can be applied by calling this function multiple times or using the vararg overload. The border and overall layout size are not affected by this shadow.

If shape is set, the shadow will be applied to the shape's bounds.

This property is not inherited.

Parameters
value: Shadow

The Shadow properties (color, offset, blurRadius) for the inner shadow.

innerShadow

fun innerShadow(vararg value: Shadow): Unit

Applies one or more inner shadow effects to the component. These shadows are drawn inside the bounds of the component. The border and overall layout size are not affected by these shadows.

This property is not inherited.

Parameters
vararg value: Shadow

A vararg of Shadow properties to apply as inner shadows.

left

fun left(value: Dp): Unit

Offsets the component horizontally from its original calculated left position. Positive values shift the component to the right, negative to the left.

This property is not inherited

Parameters
value: Dp

The amount to offset from the left edge.

See also
top
right
bottom
offset

letterSpacing

fun letterSpacing(value: TextUnit): Unit

Sets the letter spacing for the text. This property is inherited by child text components if not overridden. This affects text layout and rendering, and is a component of a TextStyle.

This property is inherited.

Parameters
value: TextUnit

The letter spacing in TextUnit (e.g., 0.5.sp).

See also
textStyle
TextStyle

lineBreak

fun lineBreak(value: LineBreak): Unit

Sets the line breaking strategy for text. This property is inherited by child text components if not overridden. This affects text layout and is a component of a TextStyle.

This property is inherited.

Parameters
value: LineBreak

The LineBreak strategy to apply.

See also
textStyle
TextStyle

lineHeight

fun lineHeight(value: TextUnit): Unit

Sets the line height for the text. This property is inherited by child text components if not overridden. This affects text layout and is a component of a TextStyle.

This property is inherited.

Parameters
value: TextUnit

The line height in TextUnit (e.g., 20.sp) or TextUnit.Unspecified.

See also
textStyle
TextStyle

maxHeight

fun maxHeight(value: Dp): Unit

Constrains the maximum height of the component. The component's height, including padding, will be at most this value.

This property is not inherited

Parameters
value: Dp

The maximum height.

maxSize

fun maxSize(size: DpSize): Unit

Constrains the maximum size (width and height) of the component. The component's dimensions, including padding, will be at most these values.

This property is not inherited

Parameters
size: DpSize

The maximum size (DpSize).

maxSize

fun maxSize(width: Dp, height: Dp): Unit

Constrains the maximum width and height of the component. The component's dimensions, including padding, will be at most these values.

This property is not inherited

Parameters
width: Dp

The maximum width.

height: Dp

The maximum height.

maxWidth

fun maxWidth(value: Dp): Unit

Constrains the maximum width of the component. The component's width, including padding, will be at most this value.

This property is not inherited

Parameters
value: Dp

The maximum width.

minHeight

fun minHeight(value: Dp): Unit

Constrains the minimum height of the component. The component's height, including padding, will be at least this value.

This property is not inherited

Parameters
value: Dp

The minimum height.

minSize

fun minSize(size: DpSize): Unit

Constrains the minimum size (width and height) of the component. The component's dimensions, including padding, will be at least these values.

This property is not inherited

Parameters
size: DpSize

The minimum size (DpSize).

minSize

fun minSize(width: Dp, height: Dp): Unit

Constrains the minimum width and height of the component. The component's dimensions, including padding, will be at least these values.

This property is not inherited

Parameters
width: Dp

The minimum width.

height: Dp

The minimum height.

minWidth

fun minWidth(value: Dp): Unit

Constrains the minimum width of the component. The component's width, including padding, will be at least this value.

This property is not inherited

Parameters
value: Dp

The minimum width.

right

fun right(value: Dp): Unit

Offsets the component horizontally from its original calculated right position. Positive values shift the component to the left (further from the right edge), negative to the right.

This property is not inherited

Parameters
value: Dp

The amount to offset from the right edge.

See also
left
top
bottom
offset

rotationX

fun rotationX(value: Float): Unit

Rotates the component around the X-axis through its center.

This property is not inherited

Parameters
value: Float

The rotation angle in degrees.

rotationY

fun rotationY(value: Float): Unit

Rotates the component around the Y-axis through its center.

This property is not inherited

Parameters
value: Float

The rotation angle in degrees.

rotationZ

fun rotationZ(value: Float): Unit

Rotates the component around the Z-axis (perpendicular to the screen) through its center.

This property is not inherited

Parameters
value: Float

The rotation angle in degrees.

scale

fun scale(value: @FloatRange(from = 0.0) Float): Unit

Scales the component uniformly (both horizontally and vertically) around its center pivot point.

Setting scale will override the horizontal scaling set by a previous call to scaleX and the previous vertical scaling set by calling scaleY.

This property is not inherited

Parameters
value: @FloatRange(from = 0.0) Float

The scaling factor for both X and Y axes. 1.0f is no scale.

scaleX

fun scaleX(value: @FloatRange(from = 0.0) Float): Unit

Scales the component horizontally around its center pivot point.

Setting scaleX will override the horizontal scaling set by a previous call to scale.

This property is not inherited

Parameters
value: @FloatRange(from = 0.0) Float

The scaling factor for the X-axis. 1.0f is no scale.

scaleY

fun scaleY(value: @FloatRange(from = 0.0) Float): Unit

Scales the component vertically around its center pivot point.

Setting scaleX will override the vertical scaling set by a previous call to scale.

This property is not inherited

Parameters
value: @FloatRange(from = 0.0) Float

The scaling factor for the Y-axis. 1.0f is no scale.

shape

fun shape(value: Shape): Unit

Sets the Shape for the component. This shape is used for clipping (clip), background rendering (background), and border rendering.

If shape is not specified then a androidx.compose.ui.graphics.RectangleShape is used.

This property is not inherited

Parameters
value: Shape

The shape to apply.

size

fun size(value: Dp): Unit

Sets the preferred width and height of the component to the same value. The actual size will also depend on the parent's constraints and other modifiers. The specified size includes any padding.

This property is not inherited

Parameters
value: Dp

The preferred width and height in Dp.

See also
size

size

fun size(value: DpSize): Unit

Sets the preferred width and height of the component using a DpSize object. The actual size will also depend on the parent's constraints and other modifiers. The specified size includes any padding.

This property is not inherited

Parameters
value: DpSize

The preferred size.

See also
size

size

fun size(width: Dp, height: Dp): Unit

Sets the preferred width and height of the component. The actual size will also depend on the parent's constraints and other modifiers. The specified dimensions includes both contentPadding and externalPadding.

This property is not inherited

Parameters
width: Dp

The preferred width in Dp.

height: Dp

The preferred height in Dp.

See also
size

state

fun <T : Any?> state(
    key: StyleStateKey<T>,
    value: Style,
    active: (key: StyleStateKey<T>, state: StyleState) -> Boolean
): Unit

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.

textAlign

fun textAlign(value: TextAlign): Unit

Sets the text alignment (e.g., start, end, center). This property is inherited by child text components if not overridden. This affects text layout and is a component of a TextStyle.

This property is inherited.

Parameters
value: TextAlign

The TextAlign to apply.

See also
textStyle
TextStyle

textDecoration

fun textDecoration(value: TextDecoration): Unit

Sets the text decoration (e.g., underline, line-through). This property is inherited by child text components if not overridden. This affects drawing only and is a component of a TextStyle.

This property is inherited.

Parameters
value: TextDecoration

The TextDecoration to apply.

See also
textStyle
TextStyle

textDirection

fun textDirection(value: TextDirection): Unit

Sets the text direction (e.g., LTR, RTL, content-based). This property is inherited by child text components if not overridden. This affects text layout and is a component of a TextStyle.

This property is inherited.

Parameters
value: TextDirection

The TextDirection to apply.

See also
textStyle
TextStyle

textIndent

fun textIndent(value: TextIndent): Unit

Sets the text indent (e.g., for the first line or subsequent lines). This property is inherited by child text components if not overridden. This affects text layout and is a component of a TextStyle.

This property is inherited.

Parameters
value: TextIndent

The TextIndent to apply.

See also
textStyle
TextStyle

textStyle

fun textStyle(value: TextStyle): Unit

Applies a complete TextStyle object to the component. This is a convenient way to set multiple text-related properties at once. Text properties are inherited by child text components unless overridden.

This property is inherited.

Parameters
value: TextStyle

The TextStyle to apply.

top

fun top(value: Dp): Unit

Offsets the component vertically from its original calculated top position. Positive values shift the component downwards, negative upwards.

This property is not inherited

Parameters
value: Dp

The amount to offset from the top edge.

See also
left
right
bottom
offset

transformOrigin

fun transformOrigin(value: TransformOrigin): Unit

Offset percentage along the x and y axis for which contents are rotated and scaled. The default value of 0.5f, 0.5f indicates the pivot point will be at the midpoint of the left and right as well as the top and bottom bounds of the layer. Default value is TransformOrigin.Center.

Parameters
value: TransformOrigin

The origin of the transform

translation

fun translation(offset: Offset): Unit

Translates (moves) the component by the given Offset.

This property is not inherited

Parameters
offset: Offset

The translation offset in pixels.

translation

fun translation(x: @FloatRange(from = 0.0) Float, y: @FloatRange(from = 0.0) Float): Unit

Translates (moves) the component horizontally and vertically.

This property is not inherited

Parameters
x: @FloatRange(from = 0.0) Float

The translation amount on the X-axis in pixels.

y: @FloatRange(from = 0.0) Float

The translation amount on the Y-axis in pixels.

translationX

fun translationX(value: @FloatRange(from = 0.0) Float): Unit

Translates (moves) the component horizontally. Positive values move it to the right, negative values to the left.

This property is not inherited

Parameters
value: @FloatRange(from = 0.0) Float

The translation amount on the X-axis in pixels.

translationY

fun translationY(value: @FloatRange(from = 0.0) Float): Unit

Translates (moves) the component vertically. Positive values move it down, negative values up.

This property is not inherited

Parameters
value: @FloatRange(from = 0.0) Float

The translation amount on the Y-axis in pixels.

width

fun width(fraction: @FloatRange(from = 0.0, to = 1.0) Float): Unit

Sets the width of the component to a fraction of the parent's available width. The specified width includes any padding.

This property is not inherited

Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float

The fraction of the available width (e.g., 0.5f for 50%).

width

fun width(value: Dp): Unit

Sets the preferred width of the component. The actual size will also depend on the parent's constraints and other modifiers. The specified width includes both contentPadding and externalPadding.

This property is not inherited

Parameters
value: Dp

The preferred width in Dp.

zIndex

fun zIndex(value: @FloatRange(from = 0.0) Float): Unit

Sets the Z-index of the component. Higher Z-index components are drawn on top of lower Z-index components within the same parent. This affects drawing order, not layout.

This property is not inherited

Parameters
value: @FloatRange(from = 0.0) Float

The Z-index value.

See also
zIndex

Public properties

state

val stateStyleState

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.

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.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.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.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

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.