In order to add a border to any side of a UI component in Jetpack Compose, you can extend the Modifier class with your own custom border functions that simply draw a custom line. Here's how you can achieve this: **For the top border:** fun Modifier.topBorder(strokeWidth: Dp, color: Color) = composed( factory = { val density = LocalDensity.current val strokeWidthPx = density.run { strokeWidth.toPx() } Modifier.drawBehind { val width = size.width val strokeWidthHalf = strokeWidthPx / 2 drawLine( color = color, start = Offset(x = 0f, y = strokeWidthHalf), end = Offset(x = width, y = strokeWidthHalf), strokeWidth = strokeWidthPx ) } } ) **For the bottom border:** fun Modifier.bottomBorder(strokeWidth: Dp, color: Color) = composed( factory = { val density = LocalDensity.current val strokeWidthPx = density.run { strokeWidth.toPx() } Modifier.drawBehind { val width = size.width val height = size.height - strokeWidthPx / 2 drawLine( color = color, start = Offset(x = 0f, y = height), end = Offset(x = width , y = height), strokeWidth = strokeWidthPx ) } } ) **For the left border:** fun Modifier.leftBorder(strokeWidth: Dp, color: Color) = composed( factory = { val density = LocalDensity.current val strokeWidthPx = density.run { strokeWidth.toPx() } Modifier.drawBehind { val height = size.height val strokeWidthHalf = strokeWidthPx / 2 drawLine( color = color, start = Offset(x = strokeWidthHalf, y = 0f), end = Offset(x = strokeWidthHalf, y = height), strokeWidth = strokeWidthPx ) } } ) **For the right border:** fun Modifier.rightBorder(strokeWidth: Dp, color: Color) = composed( factory = { val density = LocalDensity.current val strokeWidthPx = density.run { strokeWidth.toPx() } Modifier.drawBehind { val width = size.width - strokeWidthPx / 2 val height = size.height drawLine( color = color, start = Offset(x = width, y = 0f), end = Offset(x = width, y = height), strokeWidth = strokeWidthPx ) } } ) With these extension functions, you can easily add a border to any side of your UI component by just appending the function to the component's modifier. For example: Text( text = "Hello, World!", modifier = Modifier.rightBorder(2.dp, Color.Black) ) This will draw a black border with a thickness of 2.dp on the right side of the text.