Screen transitions by name: Compose and SwiftUI prompts
"make it smoother" means nothing to an AI. you get a random fade every time. screen transitions have names, and once you say the name, the agent picks the right API instead of guessing. here are 8 of them, each with one prompt for Jetpack Compose and one for SwiftUI.
The 8 transitions
| Name | Use it for |
|---|---|
| Crossfade | switching content inside one area: tabs, filters, loading → loaded |
| Slide / push | going deeper in a flow: list → detail, step 1 → step 2 |
| Shared element (hero) | the same object is on both screens and you want the eye to follow it |
| Container transform | tapping a card, list row or FAB that opens its own full screen |
| Scale + fade | dialogs, popovers, menus, anything that appears on top |
| Bottom sheet | short secondary tasks: filters, share, quick edit, pickers |
| Parallax scroll | detail pages with a big header image |
| Matched geometry morph | button → expanded panel, search icon → search field, moving tab indicator |
The main prompt
paste this, fill in the brackets, and use one of the names below. works in Claude, ChatGPT, Gemini or any coding agent.
You are a senior mobile UI engineer.
Add a [TRANSITION NAME] transition between [SCREEN / STATE A] and [SCREEN / STATE B] in [Jetpack Compose / SwiftUI].
Rules:
- Use the platform API for it, no third-party animation library.
- One duration and one easing for the whole transition, tell me which values you picked.
- Keep the existing navigation, state and layout as they are. Only add what the animation needs.
- If the transition needs a shared key or id, use the item's real id, not its index.
- Respect reduce motion: fall back to a simple fade.
Before writing code, list the files you will touch and what changes in each, max 5 bullets.1. Crossfade
Old content fades out while new content fades in, same place. Use it when: switching content inside one area: tabs, filters, loading → loaded.
Jetpack Compose
Crossfade between the loading, error and content states of [Screen] using AnimatedContent with fadeIn() togetherWith fadeOut(), 250 ms, keyed by the state type.SwiftUI
Crossfade between the loading, error and content states of [View]: switch on the state, give each branch .transition(.opacity) and change the state inside withAnimation(.easeInOut(duration: 0.25)).2. Slide / push
New screen slides in from the edge, old one slides out the other way. Use it when: going deeper in a flow: list → detail, step 1 → step 2.
Jetpack Compose
In my NavHost, make [ListRoute] → [DetailRoute] a horizontal push: enterTransition slideIntoContainer(SlideDirection.Start), exitTransition slideOutOfContainer(SlideDirection.Start), and the reverse for popEnter/popExit, 300 ms.SwiftUI
Make [Step A] → [Step B] a push from the trailing edge: if it is a NavigationStack keep the system push, if it is a state switch use .transition(.push(from: .trailing)) inside withAnimation, and the reverse edge when going back.
3. Shared element (hero)
One element (photo, avatar, title) flies from screen A to its spot on screen B. Use it when: the same object is on both screens and you want the eye to follow it.
Jetpack Compose
Shared element transition for the product image from [ListItem] to [DetailScreen]: wrap the NavHost in SharedTransitionLayout, use Modifier.sharedElement(rememberSharedContentState(key = "image-${item.id}"), animatedVisibilityScope) on both images, pass the scopes down instead of making them global.SwiftUI
Hero transition for the product image from the [ListItem] to [DetailView]: on iOS 18+ use .matchedTransitionSource(id: item.id, in: namespace) on the thumbnail and .navigationTransition(.zoom(sourceID: item.id, in: namespace)) on the destination; on older iOS fall back to the default push.4. Container transform
The whole card grows into the next screen. Use it when: tapping a card, list row or FAB that opens its own full screen.
Jetpack Compose
Container transform from [Card] to [DetailScreen]: inside SharedTransitionLayout put Modifier.sharedBounds(rememberSharedContentState(key = "card-${item.id}"), animatedVisibilityScope, resizeMode = RemeasureToBounds) on the card container and on the detail root, keep the card's corner radius during the animation.SwiftUI
Container transform from [Card] to [DetailView]: mark the whole card with .matchedTransitionSource(id: item.id, in: namespace) and give the destination .navigationTransition(.zoom(sourceID: item.id, in: namespace)) so the card itself grows into the screen, iOS 18+, default push below that.
5. Scale + fade
Content scales up a little from ~92% while fading in. Use it when: dialogs, popovers, menus, anything that appears on top.
Jetpack Compose
Show [Dialog / Popup] with AnimatedVisibility, enter = scaleIn(initialScale = 0.92f) + fadeIn(), exit = scaleOut(targetScale = 0.92f) + fadeOut(), 200 ms, scale from the center.SwiftUI
Show [Overlay] with .transition(.scale(scale: 0.92).combined(with: .opacity)) and toggle it inside withAnimation(.spring(duration: 0.25)).6. Bottom sheet
A panel slides up from the bottom and stops at a height, drag to dismiss. Use it when: short secondary tasks: filters, share, quick edit, pickers.
Jetpack Compose
Move [Filters / Picker] into a Material 3 ModalBottomSheet with rememberModalBottomSheetState(), drag handle on, close it with sheetState.hide() and only then remove it from composition.SwiftUI
Present [Filters / Picker] with .sheet(isPresented:) and add .presentationDetents([.medium, .large]) and .presentationDragIndicator(.visible), keep the state in the parent.7. Parallax scroll
Header image moves slower than the content while you scroll. Use it when: detail pages with a big header image.
Jetpack Compose
Parallax header on [DetailScreen]: in the LazyColumn's first item set Modifier.graphicsLayer { translationY = if (listState.firstVisibleItemIndex == 0) listState.firstVisibleItemScrollOffset * 0.5f else 0f }, read the scroll inside graphicsLayer so it does not recompose every frame.SwiftUI
Parallax header on [DetailView]: in the ScrollView give the header image .visualEffect { content, proxy in content.offset(y: -proxy.frame(in: .scrollView).minY * 0.5) }, iOS 17+, clip it to its frame.8. Matched geometry morph
One control changes shape into another on the same screen. Use it when: button → expanded panel, search icon → search field, moving tab indicator.
Jetpack Compose
Morph the [button] into the [expanded panel] on the same screen: SharedTransitionLayout + AnimatedContent on the expanded flag, Modifier.sharedBounds(rememberSharedContentState(key = "morph"), this@AnimatedContent) on both shapes, animate the corner radius too.SwiftUI
Morph the [button] into the [expanded panel]: @Namespace, .matchedGeometryEffect(id: "morph", in: namespace) on both views, show only one of them at a time, toggle inside withAnimation(.spring(duration: 0.35)).
As a Claude Code command
the repo has it as a slash command too, so you can just type the name:
mkdir -p .claude/commands
curl -o .claude/commands/name-the-transition.md https://raw.githubusercontent.com/birdeveloper/ai-prompts-for-app-developers/main/claude-code-commands/name-the-transition.md/name-the-transition container transform from ProductCard to ProductDetailScreenTips
one transition per run. three at once usually breaks navigation somewhere
shared element and container transform need a stable key. if the agent uses the list index, the wrong card animates after you filter the list
tell it your minimum OS version. zoom navigation transitions need iOS 18, scroll-based visualEffect needs iOS 17, SharedTransitionLayout needs Compose 1.7+
ask it to respect reduce motion, almost every generated animation ignores it
Frequently asked questions
What is the difference between a shared element and a container transform?
A shared element moves one thing (an image, a title) from screen A to its place on screen B. A container transform grows the whole card or row into the next screen. In Compose the first is Modifier.sharedElement, the second Modifier.sharedBounds.
Do these screen transitions need a library?
No. All 8 use platform APIs: Compose animation and navigation, Material 3 for the bottom sheet, and SwiftUI transitions. Shared element in Compose needs Compose 1.7 or newer, the SwiftUI zoom transition needs iOS 18.
Get all the prompts
the file with all 8 is prompts/08-name-the-transition.md, next to the other app prompts (sketch to screen, bug fix, tests, App Review precheck).
