semantics

Function

Android
public fun CurvedModifier.semantics(properties: CurvedSemanticsScope.() -> Unit): CurvedModifier

Allow specifying semantic properties on a curved component. Note that currently only contentDescription and traversalIndex are supported, and they can be applied to curved text and curvedComposable

Sample for setting content description and traversal order:

Parameters

propertiesThe properties to apply, SemanticsPropertyReceiver will be provided in the scope to allow access for common properties and its values.

Code Examples

CurvedSemanticsSample

@Composable
fun CurvedSemanticsSample() {
    val style =
        CurvedTextStyle(
            letterSpacing = 0.6.sp,
            letterSpacingCounterClockwise = 1.4.sp,
            color = Color.White,
        )
    Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
        CurvedLayout(modifier = Modifier.fillMaxSize()) {
            basicCurvedText(
                "2 - Left",
                style,
                CurvedModifier.semantics {
                    contentDescription = "Left"
                    traversalIndex = 2f
                },
            )
            curvedComposable { Box(Modifier.padding(5.dp).background(Color.Red).size(5.dp)) }
            basicCurvedText(
                "3 - Right",
                style,
                CurvedModifier.semantics {
                    contentDescription = "Right"
                    traversalIndex = 3f
                },
            )
        }
        Row {
            Text("Text 1", Modifier.semantics { traversalIndex = 1f })
            Spacer(Modifier.size(10.dp))
            Text("Text 4", Modifier.semantics { traversalIndex = 4f })
        }
    }
}