Skip to content

Conversation

@riggaroo
Copy link
Collaborator

@riggaroo riggaroo commented Dec 1, 2025

Compose 1.10 introduces a new way to enable and disable shared elements dynamically.

To control whether the shared element transition occurs, you can customize the
SharedContentConfig passed to rememberSharedContentState(). The isEnabled
property determines if the shared element is active.

The following example snippet demonstrates how to define a configuration that only
enables the shared transition when navigating between specific screens (e.g.,
only from A to B), while disabling it for others.

By default, if a shared element is disabled during an ongoing animation, it will
still complete the current in-progress animation, to prevent accidentally
removing in-flight animations. If you need to remove the element whilst the
animation is in progress, you can override
shouldKeepEnabledForOngoingAnimation in the SharedContentConfig interface to
return false.

@snippet-bot
Copy link

snippet-bot bot commented Dec 1, 2025

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@AjeshRPai AjeshRPai self-requested a review December 4, 2025 13:29
@riggaroo riggaroo merged commit 0dcfc0b into main Dec 4, 2025
4 checks passed
@riggaroo riggaroo deleted the riggaroo/dynamic-shared-elements branch December 4, 2025 13:33
dturner added a commit that referenced this pull request Dec 4, 2025
* main: (57 commits)
  Add `scrollableArea` snippet to GesturesSnippets (#703)
  Compose 1.10: Add snippet to create dynamic shared elements (#711)
  🤖 Update Dependencies (#723)
  Add snippet for dec jxr release. (#722)
  Add information on accessing the underlying mobile runtime (#720)
  Adds code for custom rotary (#714)
  Add snippet for b/454723857 (#716)
  Add snippet for screenshot test (#710)
  Improve namespacing and clarity (#705)
  Snippets for /training/wearables/tiles/get_started?version=3 (#704)
  Update Snippet to also support L and XL WSC (#702)
  Fix typo (#701)
  Add snippets for trigger based profiling section of ProfilingManager docs (#688)
  Add snippets for /training/wearables/tiles/versioning (#699)
  Add snippets for /training/wearables/tiles/get_started (#698)
  Add snippets for /training/wearables/data/{sync,events} (#697)
  Snippets for /training/wearables/tiles/dynamic (#695)
  Snippets for /training/wearables/data/data-items (#696)
  Add snippets for /training/wearables/tiles/debug (#694)
  Attempt to fix rendering error (#693)
  ...

# Conflicts:
#	gradle/libs.versions.toml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants