Compose Modifier

lightAnchor

Reports this composable's position to state, so that lights positioned with LightPosition.Anchored against the same state follow this composable.

lightAnchor

Source set: Common
public fun Modifier.lightAnchor(state: LightAnchorState): Modifier

Reports this composable's position to state, so that lights positioned with LightPosition.Anchored against the same state follow this composable.

Create state with remember and pass the same instance to this modifier and to every LightPosition.Anchored that should track it.

A given LightAnchorState tracks one composable at a time. If this modifier is applied to more than one composable simultaneously, the state reports whichever was placed most recently, which is rarely what was intended. When the anchored composable leaves the composition the state is cleared and the lights using it stop contributing.

Parameters

state the anchor to publish this composable's position to.
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: