Skip to content

Instantly share code, notes, and snippets.

@linreal
Created January 25, 2026 13:52
Show Gist options
  • Select an option

  • Save linreal/7017679e9adf5cae1687eef69f0aad90 to your computer and use it in GitHub Desktop.

Select an option

Save linreal/7017679e9adf5cae1687eef69f0aad90 to your computer and use it in GitHub Desktop.
// Looks innocent, but creates multiple expensive layers
@Composable
fun ElegantCard(content: @Composable () -> Unit) {
Card(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
.alpha(0.95f) // Layer #1: Transparency
.clip(RoundedCornerShape(12.dp)) // Layer #2: Clipping path
.shadow(8.dp, RoundedCornerShape(12.dp)) // Layer #3: Often another layer
.background(MaterialTheme.colorScheme.surface)
) {
content()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment