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

Inherited functions

From androidx.compose.foundation.style.AlphaScope
Unit
alpha(value: @FloatRange(from = 0.0, to = 1.0) Float)

Sets the opacity of the component.

Cmn
From androidx.compose.foundation.style.AnimateStyleScope
Unit
animate(
    toSpec: AnimationSpec<Float>,
    fromSpec: AnimationSpec<Float>,
    block: () -> Unit
)

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

Cmn
From androidx.compose.foundation.style.BackgroundScope
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
From androidx.compose.foundation.style.BaselineShiftScope
Unit

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

Cmn
From androidx.compose.foundation.style.BorderScope
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
From androidx.compose.foundation.style.ClipScope
Unit
clip(value: Boolean)

Clips the component to its bounds.

Cmn
From androidx.compose.foundation.style.ColorFilterScope
Unit

Sets the ColorFilter to apply to the component.

Cmn
From androidx.compose.foundation.style.ContentColorScope
Unit

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

Cmn
Unit

Sets the preferred content color, primarily affecting text color.

Cmn
From androidx.compose.foundation.style.ContentPaddingScope
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 start edge of the component's content.

Cmn
Unit

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

Cmn
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.foundation.style.ExternalPaddingScope
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 start edge of the component.

Cmn
Unit

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

Cmn
From androidx.compose.foundation.style.FontFamilyScope
Unit

Sets the font family for the text.

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

Convert Sp to Dp.

Cmn
TextUnit

Convert Dp to Sp.

Cmn
From androidx.compose.foundation.style.FontSizeScope
Unit

Sets the font size for the text.

Cmn
From androidx.compose.foundation.style.FontStyleScope
Unit

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

Cmn
From androidx.compose.foundation.style.FontSynthesisScope
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
From androidx.compose.foundation.style.FontWeightScope
Unit

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

Cmn
From androidx.compose.foundation.style.ForegroundScope
Unit
foreground(value: Brush)

Sets the foreground brush for the component.

Cmn
Unit
foreground(value: Color)

Sets the foreground color for the component.

Cmn
From androidx.compose.foundation.style.HyphensScope
Unit
hyphens(value: Hyphens)

Sets the hyphenation strategy for text.

Cmn
From androidx.compose.foundation.style.LetterSpacingScope
Unit

Sets the letter spacing for the text.

Cmn
From androidx.compose.foundation.style.LineBreakScope
Unit

Sets the line breaking strategy for text.

Cmn
From androidx.compose.foundation.style.LineHeightScope
Unit

Sets the line height for the text.

Cmn
From androidx.compose.foundation.style.MaxSizeScope
Unit
maxHeight(value: Dp)

Constrains the maximum height of the component.

Cmn
Unit
maxWidth(value: Dp)

Constrains the maximum width of the component.

Cmn
From androidx.compose.foundation.style.MinSizeScope
Unit
minHeight(value: Dp)

Constrains the minimum height of the component.

Cmn
Unit
minWidth(value: Dp)

Constrains the minimum width of the component.

Cmn
From androidx.compose.foundation.style.PositionScope
Unit
bottom(value: Dp)

Offsets the component vertically from its original calculated bottom position.

Cmn
Unit
left(value: Dp)

Offsets the component horizontally from its original calculated left position.

Cmn
Unit
right(value: Dp)

Offsets the component horizontally from its original calculated right position.

Cmn
Unit
top(value: Dp)

Offsets the component vertically from its original calculated top position.

Cmn
From androidx.compose.foundation.style.RotationScope
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
From androidx.compose.foundation.style.ScaleScope
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
From androidx.compose.foundation.style.ShadowScope
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

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
From androidx.compose.foundation.style.ShapeScope
Unit
shape(value: Shape)

Sets the Shape for the component.

Cmn
From androidx.compose.foundation.style.SizeScope
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
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
From androidx.compose.foundation.style.StyleStateScope
Unit
<T : Any?> 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.

Cmn
From androidx.compose.foundation.style.TextAlignScope
Unit

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

Cmn
From androidx.compose.foundation.style.TextDecorationScope
Unit

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

Cmn
From androidx.compose.foundation.style.TextDirectionScope
Unit

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

Cmn
From androidx.compose.foundation.style.TextIndentScope
Unit

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

Cmn
From androidx.compose.foundation.style.TextMotionScope
Unit

Sets the text motion strategy, which can be used to optimize for readability or for smooth animations.

Cmn
From androidx.compose.foundation.style.TextStyleScope
Unit

Applies a complete TextStyle object to the component.

Cmn
From androidx.compose.foundation.style.TransformOriginScope
Unit

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

Cmn
Unit

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

Cmn
From androidx.compose.foundation.style.TranslationScope
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
From androidx.compose.foundation.style.ZIndexScope
Unit
zIndex(value: @FloatRange(from = 0.0) Float)

Sets the Z-index of the component.

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
From androidx.compose.foundation.style.StyleStateScope
StyleState

The state of the component. applying this style.

Cmn