Introducing our new Modern UI Kit built for Compose & Kotlin Check it out

innerShadow

Common

Modifier in Compose Ui

Draws an inner shadow on top of the rest of the content with the geometry specified by the given shape and the shadow properties defined by the [InnerShadow]. This is different than [Modifier.shadow] as this does not introduce a graphicsLayer to render elevation based shadows. Additionally this shadow will render only within the geometry and can be used to provide a recessed like visual effect. This shadow is rendered without a single light source and will render consistently regardless of the on screen position of the content.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.ui:ui:1.9.0-alpha04")
}

Overloads

@Stable
fun Modifier.innerShadow(shape: Shape, innerShadow: InnerShadow): Modifier

Parameters

namedescription
shapeDefines the geometry of the shape
innerShadowSpecify the properties of the shadow like radius, spread, offset and fill properties like the color or brush
@Stable
fun Modifier.innerShadow(shape: Shape, block: InnerShadowScope.() -> Unit): Modifier

Parameters

namedescription
shapeDefines the geometry of the shadow
blockblock on [InnerShadowScope] where you define the shadow properties.

Code Example

InnerShadowSample

@Composable
fun InnerShadowSample() {
    Box(Modifier.size(100.dp, 100.dp).innerShadow(RectangleShape, InnerShadow(12.dp)))
}
by @alexstyl