How do I draw a `Box` with a border on only one side?
m
How do I draw a
Box
with a border on only one side?
👀 1
z
Create a custom shape and pass it to
Modifier.border
m
That link doesn't work but I get what you mean. I hoped there is something built in that I'm not aware of. Thanks!
z
Huh i was trying to link to a third party doc but the links don’t work: https://foso.github.io/Jetpack-Compose-Playground/cookbook/how_to_create_custom_shape/
👍 1
Ugh that did though. How do I computer
blob sweat smile 1
n
I just saw the @Zach Klippenstein (he/him) [MOD] link after try to implement by myself… 😅 Anyway… here it is…
Copy code
Box(modifier = Modifier
    .size(200.dp, 200.dp)
    .border(
        width = 16.dp,
        color = Color.Red,
        shape = object: Shape {
            override fun createOutline(
                size: Size,
                layoutDirection: LayoutDirection,
                density: Density
            ): Outline {
                return Outline.Generic(
                    // Just left border
                    Path().apply {
                        moveTo(0f, 0f)
                        lineTo(0f, size.height)
                        lineTo(16f, size.height)
                        lineTo(16f, 0f)
                        close()
                    }
                )
            }
        }
    )
)
👍 1