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
name | description |
---|---|
shape | Defines the geometry of the shadow |
dropShadow | Specify the properties of the shadow like radius, spread, and fill properties like the color or brush |
offset | Optional offset parameter that the shadow should be translated by |
@Stable
fun Modifier.dropShadow(shape: Shape, block: DropShadowScope.() -> Unit)
Parameters
name | description |
---|---|
shape | Defines the geometry of the shadow |
block | block 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)))
}