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

dropShadow

Common

Modifier in Compose Ui

Draws a drop shadow behind the rest of the content with the geometry specified by the given shape and the shadow properties defined by the [DropShadow]. This is different than [Modifier.shadow] as this does not introduce a graphicsLayer to render elevation based shadows. 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.dropShadow(
    shape: Shape,
    dropShadow: DropShadow,
    offset: DpOffset = DpOffset.Zero,
): Modifier

Parameters

namedescription
shapeDefines the geometry of the shadow
dropShadowSpecify the properties of the shadow like radius, spread, and fill properties like the color or brush
offsetOptional offset parameter that the shadow should be translated by
@Stable
fun Modifier.dropShadow(shape: Shape, block: DropShadowScope.() -> Unit)

Parameters

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

Code Example

DropShadowSample

@Composable
fun DropShadowSample() {
    Box(Modifier.size(100.dp, 100.dp).dropShadow(RectangleShape, DropShadow(12.dp)))
}
by @alexstyl