Compose Modifier

offset

Offset the content by (x dp, y dp).

OffsetModifier

@Sampled
@Composable
fun OffsetModifier() {
    // This text will be offset (10.dp, 20.dp) from the center of the available space. In the
    // right-to-left context, the offset will be (-10.dp, 20.dp).
    Text(
        "Layout offset modifier sample",
        Modifier.fillMaxSize().wrapContentSize(Alignment.Center).offset(10.dp, 20.dp),
    )
}

OffsetPxModifier

@Sampled
@Composable
fun OffsetPxModifier() {
    // This text will be offset in steps of 10.dp from the top left of the available space in
    // left-to-right context, and from top right in right-to-left context.
    var offset by remember { mutableStateOf(0) }
    Text(
        "Layout offset modifier sample",
        Modifier.clickable { offset += 10 }.offset { IntOffset(offset, offset) },
    )
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: