Fade

data class Fade(highlightColor: Color, val animationSpec: InfiniteRepeatableSpec<Float>) : PlaceholderHighlight

A PlaceholderHighlight implementation that fades a solid color in and out.

This creates a simple breathing effect by animating the opacity of a highlight color over the placeholder. The fade effect is subtle and works well for most content types.

Example usage:

Box(
modifier = Modifier
.size(100.dp)
.placeholder(
visible = isLoading,
highlight = Fade(
highlightColor = Color.White.copy(alpha = 0.5f),
animationSpec = infiniteRepeatable(
animation = tween(durationMillis = 800),
repeatMode = RepeatMode.Reverse
)
)
)
)

Parameters

highlightColor

The color of the fade overlay

animationSpec

The animation specification controlling the fade timing

See also

for a default configuration

Constructors

Link copied to clipboard
constructor(highlightColor: Color, animationSpec: InfiniteRepeatableSpec<Float>)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun alpha(progress: Float): Float

Return the desired alpha value used for drawing the Brush returned from brush.

Link copied to clipboard
open override fun brush(progress: Float, size: Size): Brush

Return a Brush to draw for the given progress and size.