fade

fun PlaceholderHighlight.Companion.fade(highlightColor: Color, animationSpec: InfiniteRepeatableSpec<Float> = PlaceholderDefaults.fadeAnimationSpec): PlaceholderHighlight(source)

Creates a Fade brush with the given initial and target colors.

Parameters

highlightColor

the color of the highlight which is faded in/out.

animationSpec

the AnimationSpec to configure the animation.

Samples

import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import io.github.fornewid.placeholder.foundation.PlaceholderHighlight
import io.github.fornewid.placeholder.foundation.fade
import io.github.fornewid.placeholder.foundation.placeholder
import io.github.fornewid.placeholder.foundation.shimmer

fun main() { 
   //sampleStart 
   Text(
    text = "Content to display after content has loaded",
    modifier = Modifier
        .padding(16.dp)
        .placeholder(
            visible = true,
            color = Color.Gray,
            // optional, defaults to RectangleShape
            shape = RoundedCornerShape(4.dp),
            highlight = PlaceholderHighlight.fade(
                highlightColor = Color.White,
            ),
        ),
) 
   //sampleEnd
}