Is there any way to remove the shadow from the int...
# compose-desktop
k
Is there any way to remove the shadow from the interior of the element?
Copy code
@Composable
fun FluentSurface(modifier: Modifier = Modifier, content: @Composable () -> Unit) {

    Surface(
        modifier,
        elevation = 4.dp,
        color = Color(0xb3ffffff),
        shape = RoundedCornerShape(7.dp),
        border = BorderStroke(1.dp, Color(0x66757575)),
        content = content
    )

}
k
You're using translucent fill color, so this is what you get
a
If this is a Fluent Design UI system, you'd probably be better off to do it from scratch as opposed to using the Material system underneath
k
This is meant more as a proof of concept. I was planning on rewriting it from scratch later.
Turns out you can get it to work by using BlendMode.Src and manually drawing the rounded rectangle.
message has been deleted
Copy code
@Composable
fun FluentSurface(modifier: Modifier = Modifier, elevation: Dp = 4.dp, content: @Composable () -> Unit = {}) {
    Box(modifier
        .shadow(elevation, RoundedCornerShape(7.dp))
        .drawBehind {
            drawRoundRect(
                Color(0xb3ffffff),
                cornerRadius = CornerRadius(7f, 7f),
                blendMode = BlendMode.Src
            )
        }) {
        content()
    }
}
a
Really shouldn’t have to as long as your modifier order is correct
k
I tried that. Regardless of order you get weird artifacts.
a
This surface is transparent, correct?
k
yes
a
That’s probably your culprit
My assumption is this emulates android’s elevation system, and this is one of those quirks with it
k
Changing the blend mode seems to fix it.
a
I think Kirill mentioned this
I’d be careful with blend modes, it can affect other composables too
Hence why your shadow is affected