TIL: Lorem ipsum text for Compose Previews

When working with Compose, I miss the tools:sample data that’s available in android View XML for rendering some sample data in view previews.

TIL: There’s nothing as extensive, but compose does provide a Lorem Ipsum preview parameter for previewing sample text.

@Preview
@Composable
private fun TextPreview(@PreviewParameter(LoremIpsum::class) text: String) {
    Box(
        modifier = Modifier
            .size(128.dp)
            .background(Color.LightGray)
            .padding(8.dp),
    ) {
        Text(text = text, overflow = TextOverflow.Ellipsis)
    }
}
Screenshot of the output showing a block of text consisting of random lorem ipsum
The output