Shadow

Class

Common
class Shadow
private constructor(
    val radius: Dp,
    val spread: Dp,
    val offset: DpOffset,
    color: Color,
    brush: Brush?,
    @FloatRange(from = 0.0, to = 1.0) alpha: Float,
    val blendMode: BlendMode,
)

Group of parameters that represent how a drop shadow or inner shadow should be rendered.

Secondary Constructors

constructor(
    radius: Dp,
    brush: Brush,
    spread: Dp = 0.dp,
    offset: DpOffset = DpOffset.Zero,
    @FloatRange(from = 0.0, to = 1.0) alpha: Float = 1f,
    blendMode: BlendMode = DefaultBlendMode,
) : this(
    radius = radius,
    spread = spread,
    offset = offset,
    color = Color.Black,
    brush = brush,
    alpha = alpha,
    blendMode = blendMode,
)

Creates a group of parameters that represent how a drop shadow or inner shadow should be rendered.

Parameters

radiusThe blur radius of the shadow
brushBrush used to blend against a mask defined by the shadow geometry
spreadOptional parameter to grow the shadow geometry by
offsetOptional parameter to offset the shadow within the geometry bounds
alphaOptional opacity of the shadow
blendModeOptional blending algorithm used by the shadow
constructor(
    radius: Dp,
    color: Color = Color.Black,
    spread: Dp = 0.dp,
    offset: DpOffset = DpOffset.Zero,
    @FloatRange(from = 0.0, to = 1.0) alpha: Float = 1f,
    blendMode: BlendMode = DefaultBlendMode,
) : this(
    radius = radius,
    spread = spread,
    offset = offset,
    color = if (color.isSpecified) color else Color.Black,
    brush = null,
    alpha = alpha,
    blendMode = blendMode,
)

Creates a group of parameters that represent how a drop shadow or inner shadow should be rendered.

Parameters

radiusThe blur radius of the shadow
colorThe color of the shadow. If Color.Unspecified is provided, Color.Black will be used as a default.
spreadOptional parameter to grow the shadow geometry by
offsetOptional parameter to offset the shadow within the geometry bounds
alphaOptional opacity of the shadow
blendModeOptional blending algorithm used by the shadow

Properties

Common
val color: Color

Color of the shadow. If Color.Unspecified is provided, Color.Black will be used as a default. This color is only used if brush is null.

Common
val brush: Brush?

Optional brush to render the shadow with.

Common
val alpha: Float

Opacity of the shadow

Common
class Shadow(
    @Stable val color: Color = Color(0xFF000000),
    @Stable val offset: Offset = Offset.Zero,
    @Stable val blurRadius: Float = 0.0f,
)

A single shadow.

Functions

fun copy(
        color: Color = this.color,
        offset: Offset = this.offset,
        blurRadius: Float = this.blurRadius,
    ): Shadow

Companion Object

Properties

Common
val None = Shadow()

Constant for no shadow.