Commit 265b63d191f for woocommerce

commit 265b63d191f8cc6546df3984fdc59949b8dc395d
Author: Mike Jolley <mike.jolley@me.com>
Date:   Thu Nov 26 12:58:25 2026 +0000

    Add motion to the Ship/Pickup toggle (#70917)

    * Add motion to the Ship/Pickup toggle

    The selection slides between Ship and Pickup, and the sections that
    change swap as one movement: old ones fade out, new ones slide in, and
    the content below moves once. Keys and page load apply at once.

    * Leave no empty style attribute after a swap

    Chrome re-creates style="" when the cleared inline styles have not been
    read before the attribute is removed. Reading it first removes it for good.

    * Remove turned-around swap copies when a swap stops at once

    Turning a swap around keeps the first swap's copies fading out. A keyboard change then stopped only the second swap's copies, so the first ones kept animating after a change that should apply at once.

    * Keep the Ship/Pickup indicator's size when it turns around

    A new indicator replaces one that still slides and started its stretch at the resting size, so reversing mid-stretch made its border jump. The stretch now starts from the size of the indicator it replaces.

    * Only cancel the swap's own slide when a swap stops

    Stopping a swap cancelled every animation on the sections after the group, including a theme's or extension's looping animation. Cancel only the translate transitions that the swap starts.

    * Stop the running swap after each swap-sections test

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    * Use the shared inline style cleanup in the section swap

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    * Change the layout at once when Ship or Pickup swaps with reduced motion

    With reduced motion, the content below held its place until the old sections faded out, then jumped. Now the layout changes with the choice, and the new sections fade in without a delay.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    ---------

    Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

diff --git a/plugins/woocommerce/changelog/add-cart-checkout-motion-ship-pickup b/plugins/woocommerce/changelog/add-cart-checkout-motion-ship-pickup
new file mode 100644
index 00000000000..42cef9cbfcf
--- /dev/null
+++ b/plugins/woocommerce/changelog/add-cart-checkout-motion-ship-pickup
@@ -0,0 +1,4 @@
+Significance: patch
+Type: tweak
+
+Switching between Ship and Pickup in Checkout now slides the selection and swaps the delivery sections smoothly instead of jumping.
diff --git a/plugins/woocommerce/client/blocks/assets/css/abstracts/_motion.scss b/plugins/woocommerce/client/blocks/assets/css/abstracts/_motion.scss
index 0aa1430a07e..635e3ca6ad5 100644
--- a/plugins/woocommerce/client/blocks/assets/css/abstracts/_motion.scss
+++ b/plugins/woocommerce/client/blocks/assets/css/abstracts/_motion.scss
@@ -8,6 +8,8 @@
 $wc-scale-press: 0.97;
 $wc-scale-icon-from: 0.8;
 $wc-blur-icon: 4px;
+// How far sections move when a choice swaps them, such as Ship or Pickup.
+$wc-swap-distance: 24px;

 // Rows after this number share the last stagger step, so long lists do not wait.
 $wc-stagger-cap: 7;
@@ -80,8 +82,8 @@ $wc-stagger-cap: 7;
 }

 // Fades content out and keeps it hidden until it unmounts.
-@mixin motion-fade-out() {
-	animation: wc-fade-out motion-duration(md) motion-easing(subtle) forwards;
+@mixin motion-fade-out($duration: md) {
+	animation: wc-fade-out motion-duration($duration) motion-easing(subtle) forwards;
 }

 // Content that appears. It fades in. When motion is allowed, it also plays $keyframes over $duration.
@@ -94,14 +96,14 @@ $wc-stagger-cap: 7;
 	}
 }

-// Content that goes. It fades out. When motion is allowed, it also plays $keyframes. It keeps the end state until it
-// unmounts.
-@mixin motion-exit($keyframes) {
-	@include motion-fade-out;
+// Content that goes. It fades out over $duration. When motion is allowed, it also plays $keyframes. It keeps the end
+// state until it unmounts.
+@mixin motion-exit($keyframes, $duration: md) {
+	@include motion-fade-out($duration);
 	@include motion-safe {
 		animation:
-			wc-fade-out motion-duration(md) motion-easing(subtle) forwards,
-			$keyframes motion-duration(md) motion-easing(expressive) forwards;
+			wc-fade-out motion-duration($duration) motion-easing(subtle) forwards,
+			$keyframes motion-duration($duration) motion-easing(expressive) forwards;
 	}
 }

@@ -129,6 +131,46 @@ $wc-stagger-cap: 7;
 	}
 }

+// The timing for `playSwap` in base-utils, on the element whose children are the sections. Copies of the old
+// sections fade out over `sm` and move the way the selection moved. Then the new sections fade in and slide in from the
+// other side, and the sections after them slide to their new position. With reduced motion, the layout changes at once
+// and the new sections fade in.
+// Give the element `motion-collapse` too, for its height.
+@mixin motion-swap() {
+	&[data-wc-swapping] {
+		position: relative;
+	}
+
+	> [data-wc-swap-copy],
+	> [data-wc-swap-in] {
+		--wc-swap-distance: #{$wc-swap-distance};
+	}
+
+	> [data-wc-swap-copy="left"],
+	> [data-wc-swap-in="left"] {
+		--wc-swap-distance: -#{$wc-swap-distance};
+	}
+
+	> [data-wc-swap-copy] {
+		@include motion-exit(wc-swap-out, sm);
+	}
+
+	// With reduced motion, the old sections have no copies to wait for, so the new sections fade in at once.
+	> [data-wc-swap-in] {
+		@include motion-enter(wc-swap-in, lg);
+
+		@include motion-safe {
+			animation-delay: motion-duration(sm);
+		}
+	}
+
+	> [data-wc-swap-after] {
+		@include motion-safe {
+			transition: motion-move(translate, lg, balanced);
+		}
+	}
+}
+
 // Sets --wc-motion-index on sibling rows. Rows after $wc-stagger-cap share the last index. `--wc-motion-index` is
 // registered as an integer in `assets/css/style.scss`, so `sibling-index()` counts the row, not the child that reads
 // it. Browsers without `sibling-index()` use `nth-child`. The `@supports` tests use a literal time, not `var()`.
diff --git a/plugins/woocommerce/client/blocks/assets/css/style.scss b/plugins/woocommerce/client/blocks/assets/css/style.scss
index 000577876ba..173a82a8799 100644
--- a/plugins/woocommerce/client/blocks/assets/css/style.scss
+++ b/plugins/woocommerce/client/blocks/assets/css/style.scss
@@ -46,6 +46,19 @@
 	}
 }

+// Sections that a choice swaps move the way the selection moved. `motion-swap` sets the distance.
+@keyframes wc-swap-out {
+	to {
+		translate: var(--wc-swap-distance) 0;
+	}
+}
+
+@keyframes wc-swap-in {
+	from {
+		translate: calc(-1 * var(--wc-swap-distance)) 0;
+	}
+}
+
 body.wc-modal--open {
 	overflow: hidden;
 }
diff --git a/plugins/woocommerce/client/blocks/assets/js/base/utils/animate-collapse.ts b/plugins/woocommerce/client/blocks/assets/js/base/utils/animate-collapse.ts
index bb1911c33bc..cb6b0d58018 100644
--- a/plugins/woocommerce/client/blocks/assets/js/base/utils/animate-collapse.ts
+++ b/plugins/woocommerce/client/blocks/assets/js/base/utils/animate-collapse.ts
@@ -156,17 +156,13 @@ export const animateCollapse = (
 };

 /**
- * Collapses an inert copy of an element in its place, so that the element itself can unmount at once. Use it for a
- * form that goes, so that its fields stop counting immediately. The copy has no `id`, `name`, or `for` attributes, its
- * fields are not validated, and it is removed when the collapse ends. Call it just before the element unmounts, while
- * it is still in the page.
+ * Copies an element as inert content that only shows, so that the element itself can unmount at once. The copy has no
+ * `id`, `name`, or `for` attributes, its fields are not validated, and assistive technology skips it. Its selects show
+ * the selected options.
  *
- * @param element The element that unmounts.
+ * @param element The element to copy. It can already be out of the page.
  */
-export const collapseCopy = ( element: HTMLElement | null ): void => {
-	if ( typeof element?.getAnimations !== 'function' ) {
-		return;
-	}
+export const inertCopy = ( element: HTMLElement ): HTMLElement => {
 	const copy = element.cloneNode( true ) as HTMLElement;
 	[
 		copy,
@@ -189,6 +185,21 @@ export const collapseCopy = ( element: HTMLElement | null ): void => {
 	} );
 	copy.setAttribute( 'inert', '' );
 	copy.setAttribute( 'aria-hidden', 'true' );
+	return copy;
+};
+
+/**
+ * Collapses an inert copy of an element in its place, so that the element itself can unmount at once. Use it for a
+ * form that goes, so that its fields stop counting immediately. The copy has no `id`, `name`, or `for` attributes, and
+ * it is removed when the collapse ends. Call it just before the element unmounts, while it is still in the page.
+ *
+ * @param element The element that unmounts.
+ */
+export const collapseCopy = ( element: HTMLElement | null ): void => {
+	if ( typeof element?.getAnimations !== 'function' ) {
+		return;
+	}
+	const copy = inertCopy( element );
 	copy.setAttribute( COPY, element.className );
 	// A motion that runs continues from its current position.
 	if ( element.hasAttribute( ATTRIBUTE ) ) {
diff --git a/plugins/woocommerce/client/blocks/assets/js/base/utils/index.js b/plugins/woocommerce/client/blocks/assets/js/base/utils/index.js
index f42a66b8c92..cbc5c08943e 100644
--- a/plugins/woocommerce/client/blocks/assets/js/base/utils/index.js
+++ b/plugins/woocommerce/client/blocks/assets/js/base/utils/index.js
@@ -21,3 +21,4 @@ export * from './use-return-focus';
 export * from './when-animations-end';
 export * from './animate-collapse';
 export * from './input-modality';
+export * from './swap-sections';
diff --git a/plugins/woocommerce/client/blocks/assets/js/base/utils/swap-sections.ts b/plugins/woocommerce/client/blocks/assets/js/base/utils/swap-sections.ts
new file mode 100644
index 00000000000..679e2651e7b
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/assets/js/base/utils/swap-sections.ts
@@ -0,0 +1,302 @@
+/**
+ * Internal dependencies
+ */
+import {
+	animateCollapse,
+	clearInlineStyle,
+	inertCopy,
+} from './animate-collapse';
+import { whenAnimationsEnd } from './when-animations-end';
+
+// The `motion-swap` mixin styles the container, the copies, and the sections by these attributes.
+const SWAPPING = 'data-wc-swapping';
+const COPY = 'data-wc-swap-copy';
+const ENTERING = 'data-wc-swap-in';
+const AFTER = 'data-wc-swap-after';
+
+// After this time, a motion helper ends even if the browser never reports the end of an animation. A swap takes 400ms.
+export const MOTION_SAFETY_TIMEOUT = 1000;
+
+type Place = { top: number; left: number; width: number; opacity: string };
+
+/**
+ * Where the sections of a container were before a choice swaps some of them. Create it with `captureSwap`.
+ */
+export type SwapSnapshot = {
+	container: HTMLElement;
+	places: Map< HTMLElement, Place >;
+	// The computed height, which is the current height while the last swap still changes it.
+	height: string;
+	direction: 'left' | 'right';
+};
+
+// Stops the swap that runs in a container. Only one block swaps sections, so the state can be in the module.
+const running = new WeakMap< HTMLElement, ( removeCopies: boolean ) => void >();
+
+const sectionsOf = ( container: HTMLElement ) =>
+	Array.from( container.children ).filter(
+		( child ): child is HTMLElement =>
+			child instanceof HTMLElement && ! child.hasAttribute( COPY )
+	);
+
+// Runs `callback` when the animations of all `elements` end. Returns a function that cancels it.
+const whenAllAnimationsEnd = (
+	elements: Element[],
+	callback: () => void
+): ( () => void ) => {
+	let pending = elements.length;
+	if ( pending === 0 ) {
+		callback();
+		return () => undefined;
+	}
+	const cancels = elements.map( ( element ) =>
+		whenAnimationsEnd( element, () => {
+			pending--;
+			if ( pending === 0 ) {
+				callback();
+			}
+		} )
+	);
+	return () => cancels.forEach( ( cancel ) => cancel() );
+};
+
+/**
+ * Splits the sections of a swap. The group runs from the first section that changes to the last, in the old order and
+ * in the new one, and includes the sections between them that stay. The sections after the group stay where they are
+ * in the layout, but move with its height.
+ *
+ * @param before The sections before the change, in order.
+ * @param now    The sections after the change, in order.
+ * @return The group as it was (`leaving`), the group as it is (`entering`), and the sections after it (`after`).
+ */
+export const getSwapGroups = < T >( before: T[], now: T[] ) => {
+	const stays = ( item: T ) =>
+		before.includes( item ) && now.includes( item );
+	const hasChange = ( list: T[] ) => list.some( ( item ) => ! stays( item ) );
+	const changesBefore = ( item: T ) =>
+		hasChange( before.slice( 0, before.indexOf( item ) ) ) ||
+		hasChange( now.slice( 0, now.indexOf( item ) ) );
+	const changesAfter = ( item: T ) =>
+		hasChange( before.slice( before.indexOf( item ) + 1 ) ) ||
+		hasChange( now.slice( now.indexOf( item ) + 1 ) );
+	const isInGroup = ( item: T ) =>
+		! stays( item ) || ( changesBefore( item ) && changesAfter( item ) );
+	return {
+		leaving: before.filter( isInGroup ),
+		entering: now.filter( isInGroup ),
+		after: now.filter(
+			( item ) =>
+				stays( item ) && changesBefore( item ) && ! changesAfter( item )
+		),
+	};
+};
+
+/**
+ * Records where the sections of `container` are, just before a choice swaps some of them, such as Ship or Pickup. Call
+ * it from the event handler that makes the change, then call `playSwap` before paint, after the sections change.
+ *
+ * @param container The element whose children are the sections.
+ * @param direction The way that the selection moved on the screen: 1 to the right, -1 to the left.
+ * @return The snapshot for `playSwap`, or `null` when the browser has no Web Animations API, such as in Jest.
+ */
+export const captureSwap = (
+	container: Element | null,
+	direction: number
+): SwapSnapshot | null => {
+	if (
+		! ( container instanceof HTMLElement ) ||
+		typeof container.getAnimations !== 'function'
+	) {
+		return null;
+	}
+	// Where the sections are on the screen, so a swap that still runs continues from its current position.
+	const box = container.getBoundingClientRect();
+	const places = new Map(
+		sectionsOf( container ).map( ( section ): [ HTMLElement, Place ] => {
+			const rect = section.getBoundingClientRect();
+			return [
+				section,
+				{
+					top: rect.top - box.top - container.clientTop,
+					left: rect.left - box.left - container.clientLeft,
+					width: rect.width,
+					opacity: getComputedStyle( section ).opacity,
+				},
+			];
+		} )
+	);
+	return {
+		container,
+		places,
+		height: getComputedStyle( container ).height,
+		direction: direction < 0 ? 'left' : 'right',
+	};
+};
+
+/**
+ * Ends a swap that runs in `container` at once, for a change that applies immediately, such as after a key press.
+ * Call it from the event handler that makes the change.
+ *
+ * @param container The element whose children are the sections.
+ */
+export const stopSwap = ( container: Element | null ) => {
+	if ( container instanceof HTMLElement ) {
+		running.get( container )?.( true );
+	}
+};
+
+/**
+ * Swaps the group of sections that changed as one movement. Give the container the `motion-swap` mixin.
+ *
+ * Inert copies of the old sections fade out and move the way the selection moved. The real sections already changed,
+ * so a form that goes stops counting at once. The sections after the group hold their old position until the copies
+ * have gone, so content that loads meanwhile is in place before anything moves. Then they slide to their new position,
+ * the height of the container changes once, and the new sections fade in and slide in from the other side. A new swap
+ * continues from the current position. With reduced motion, nothing moves: the layout changes at once, with the choice,
+ * and the new sections fade in.
+ *
+ * @param snapshot The snapshot from `captureSwap`.
+ */
+export const playSwap = ( snapshot: SwapSnapshot ) => {
+	const { container, places, height, direction } = snapshot;
+	const { leaving, entering, after } = getSwapGroups(
+		Array.from( places.keys() ),
+		sectionsOf( container )
+	);
+	if ( ! leaving.length && ! entering.length ) {
+		return;
+	}
+	running.get( container )?.( false );
+
+	let frame = 0;
+	let isStopped = false;
+	const cancels: Array< () => void > = [];
+	// Without movement, a hold would only delay the change of the layout until after the fade. Copies of the old
+	// sections would then cover the content that takes their place, so they are left out too.
+	const isReduced = window.matchMedia(
+		'(prefers-reduced-motion: reduce)'
+	).matches;
+
+	// Each copy shows where its section was, above the content that now takes its place.
+	const copies = ( isReduced ? [] : leaving ).map( ( section ) => {
+		const { top, left, width, opacity } = places.get( section ) as Place;
+		const copy = inertCopy( section );
+		copy.setAttribute( COPY, direction );
+		Object.assign( copy.style, {
+			position: 'absolute',
+			boxSizing: 'border-box',
+			margin: '0',
+			top: `${ top }px`,
+			left: `${ left }px`,
+			width: `${ width }px`,
+			opacity,
+		} );
+		return copy;
+	} );
+
+	// Moves the sections after the group back to where they were, wherever the layout puts them now. Reading the
+	// layout also applies the styles that changed before, so entrances that the last swap started can start again.
+	const hold = () => {
+		after.forEach( ( section ) =>
+			section.style.removeProperty( 'translate' )
+		);
+		const box = container.getBoundingClientRect();
+		const shifts = after.map(
+			( section ) =>
+				( places.get( section )?.top ?? 0 ) -
+				( section.getBoundingClientRect().top -
+					box.top -
+					container.clientTop )
+		);
+		after.forEach( ( section, index ) => {
+			section.style.translate = `0 ${ shifts[ index ] }px`;
+		} );
+	};
+	const keepHolding = () => {
+		hold();
+		frame = requestAnimationFrame( keepHolding );
+	};
+
+	const stop = ( removeCopies: boolean ) => {
+		if ( isStopped ) {
+			return;
+		}
+		isStopped = true;
+		if ( running.get( container ) === stop ) {
+			running.delete( container );
+		}
+		cancelAnimationFrame( frame );
+		cancels.forEach( ( cancel ) => cancel() );
+		animateCollapse( container, true, false );
+		container.removeAttribute( SWAPPING );
+		entering.forEach( ( section ) => section.removeAttribute( ENTERING ) );
+		after.forEach( ( section ) => {
+			section.removeAttribute( AFTER );
+			clearInlineStyle( section, 'translate' );
+		} );
+		if ( removeCopies ) {
+			// Includes the copies of a swap that this one turned around, which still fade out.
+			Array.from( container.children )
+				.filter( ( child ) => child.hasAttribute( COPY ) )
+				.forEach( ( copy ) => copy.remove() );
+			// A slide that still runs would keep moving the sections from where they were, so end it at once. Other
+			// animations, such as a theme's, keep running.
+			after.forEach( ( section ) =>
+				section
+					.getAnimations()
+					.filter(
+						( animation ) =>
+							( animation as CSSTransition )
+								.transitionProperty === 'translate'
+					)
+					.forEach( ( animation ) => animation.cancel() )
+			);
+		}
+	};
+
+	const release = () => {
+		cancelAnimationFrame( frame );
+		hold();
+		// The slide starts from the held position.
+		container.getBoundingClientRect();
+		after.forEach( ( section ) => {
+			section.setAttribute( AFTER, '' );
+			clearInlineStyle( section, 'translate' );
+		} );
+		clearInlineStyle( container, 'height' );
+		animateCollapse( container, true, true, { height } );
+		cancels.push(
+			whenAllAnimationsEnd( [ container, ...entering, ...after ], () =>
+				stop( true )
+			)
+		);
+	};
+
+	container.setAttribute( SWAPPING, '' );
+	if ( isReduced ) {
+		// Applies the styles that changed before, so entrances that the last swap started can start again.
+		container.getBoundingClientRect();
+	} else {
+		container.style.height = height;
+		container.append( ...copies );
+		hold();
+	}
+	entering.forEach( ( section ) =>
+		section.setAttribute( ENTERING, direction )
+	);
+	copies.forEach( ( copy ) =>
+		whenAnimationsEnd( copy, () => copy.remove() )
+	);
+	const safety = window.setTimeout(
+		() => stop( true ),
+		MOTION_SAFETY_TIMEOUT
+	);
+	cancels.push( () => window.clearTimeout( safety ) );
+	running.set( container, stop );
+	if ( isReduced ) {
+		cancels.push( whenAllAnimationsEnd( entering, () => stop( true ) ) );
+		return;
+	}
+	frame = requestAnimationFrame( keepHolding );
+	cancels.push( whenAllAnimationsEnd( copies, release ) );
+};
diff --git a/plugins/woocommerce/client/blocks/assets/js/base/utils/test/swap-sections.ts b/plugins/woocommerce/client/blocks/assets/js/base/utils/test/swap-sections.ts
new file mode 100644
index 00000000000..74d45f3eb56
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/assets/js/base/utils/test/swap-sections.ts
@@ -0,0 +1,393 @@
+/**
+ * Internal dependencies
+ */
+import {
+	captureSwap,
+	getSwapGroups,
+	playSwap,
+	stopSwap,
+	type SwapSnapshot,
+} from '../swap-sections';
+
+describe( 'getSwapGroups', () => {
+	it( 'groups the sections from the first change to the last, with the sections between them that stay', () => {
+		expect(
+			getSwapGroups(
+				[ 'contact', 'method', 'shipping', 'billing', 'rates', 'pay' ],
+				[ 'contact', 'method', 'pickup', 'billing', 'pay' ]
+			)
+		).toEqual( {
+			leaving: [ 'shipping', 'billing', 'rates' ],
+			entering: [ 'pickup', 'billing' ],
+			after: [ 'pay' ],
+		} );
+	} );
+
+	it( 'includes a section that only one of the two states has', () => {
+		expect(
+			getSwapGroups(
+				[ 'method', 'shipping', 'rates', 'pay' ],
+				[ 'method', 'pickup', 'billing', 'pay' ]
+			)
+		).toEqual( {
+			leaving: [ 'shipping', 'rates' ],
+			entering: [ 'pickup', 'billing' ],
+			after: [ 'pay' ],
+		} );
+	} );
+
+	it( 'includes the sections between a change in the old order and a change in the new order', () => {
+		expect(
+			getSwapGroups( [ 'a', 'gone', 'b', 'c' ], [ 'a', 'b', 'c', 'new' ] )
+		).toEqual( {
+			leaving: [ 'gone', 'b', 'c' ],
+			entering: [ 'b', 'c', 'new' ],
+			after: [],
+		} );
+	} );
+
+	it( 'has no group when nothing changes', () => {
+		expect( getSwapGroups( [ 'a', 'b' ], [ 'a', 'b' ] ) ).toEqual( {
+			leaving: [],
+			entering: [],
+			after: [],
+		} );
+	} );
+} );
+
+// Jest has no layout or Web Animations API. In the fake, sections stack in their order, `translate` moves them, and
+// the copies and the entering sections animate until the test finishes their animations.
+const heights = new Map< Element, number >();
+
+const createAnimation = () => {
+	let resolve = () => undefined as void;
+	const animation = {
+		playState: 'running',
+		finished: new Promise< void >( ( done ) => {
+			resolve = done;
+		} ),
+		effect: { getComputedTiming: () => ( { endTime: 300 } ) },
+	};
+	return {
+		animation,
+		finish: () => {
+			animation.playState = 'finished';
+			resolve();
+		},
+	};
+};
+
+let copyFade = createAnimation();
+let entrance = createAnimation();
+
+const flush = () => new Promise( ( resolve ) => setTimeout( resolve ) );
+
+const section = ( id: string, height: number ) => {
+	const element = document.createElement( 'fieldset' );
+	element.id = id;
+	element.innerHTML = `<label for="${ id }-input">Label</label><input id="${ id }-input" name="${ id }" />`;
+	heights.set( element, height );
+	return element;
+};
+
+const topOf = ( element: Element ) => element.getBoundingClientRect().top;
+
+// The form is 430px tall before the swap.
+const style = document.createElement( 'style' );
+style.textContent = 'form { height: 430px; }';
+
+describe( 'playSwap', () => {
+	let container: HTMLFormElement;
+	let method: HTMLElement;
+	let shipping: HTMLElement;
+	let rates: HTMLElement;
+	let pay: HTMLElement;
+	// The global mock of `matchMedia` reports reduced motion. These tests allow motion, unless a test sets this.
+	let isReducedMotion: boolean;
+
+	beforeEach( () => {
+		copyFade = createAnimation();
+		entrance = createAnimation();
+		isReducedMotion = false;
+		jest.spyOn( window, 'matchMedia' ).mockImplementation(
+			( query ) =>
+				( {
+					matches: isReducedMotion && query.includes( 'reduce' ),
+				} ) as MediaQueryList
+		);
+		const running = ( fake: typeof copyFade ) =>
+			fake.animation.playState === 'running'
+				? [ fake.animation as unknown as Animation ]
+				: [];
+		HTMLElement.prototype.getAnimations = function ( this: HTMLElement ) {
+			if ( this.hasAttribute( 'data-wc-swap-copy' ) ) {
+				return running( copyFade );
+			}
+			if ( this.hasAttribute( 'data-wc-swap-in' ) ) {
+				return running( entrance );
+			}
+			return [];
+		};
+		jest.spyOn(
+			Element.prototype,
+			'getBoundingClientRect'
+		).mockImplementation( function ( this: Element ) {
+			let top = 0;
+			for ( const sibling of Array.from(
+				this.parentElement?.children ?? []
+			) ) {
+				if ( sibling === this ) {
+					break;
+				}
+				if ( ! sibling.hasAttribute( 'data-wc-swap-copy' ) ) {
+					top += heights.get( sibling ) ?? 0;
+				}
+			}
+			top += parseFloat(
+				( this as HTMLElement ).style.translate.split( ' ' )[ 1 ] ?? '0'
+			);
+			return {
+				top,
+				left: 0,
+				width: 300,
+				height: heights.get( this ) ?? 0,
+			} as DOMRect;
+		} );
+
+		method = section( 'shipping-method', 50 );
+		shipping = section( 'shipping-fields', 200 );
+		rates = section( 'shipping-option', 100 );
+		pay = section( 'payment', 80 );
+		container = document.createElement( 'form' );
+		container.append( method, shipping, rates, pay );
+		document.body.append( container );
+		document.head.append( style );
+	} );
+
+	afterEach( () => {
+		// Some tests end while the swap still runs. Stop its frame and timer before the next test.
+		stopSwap( container );
+		jest.restoreAllMocks();
+		jest.useRealTimers();
+		container.remove();
+		style.remove();
+		// @ts-expect-error The fake is not part of jsdom.
+		delete HTMLElement.prototype.getAnimations;
+	} );
+
+	const capture = ( direction: number ) =>
+		captureSwap( container, direction ) as SwapSnapshot;
+
+	// Like React: the shipping sections unmount and the pickup section mounts.
+	const switchToPickup = () => {
+		const pickup = section( 'pickup-options', 60 );
+		shipping.remove();
+		rates.remove();
+		method.after( pickup );
+		return pickup;
+	};
+
+	const copies = () =>
+		Array.from( container.querySelectorAll( '[data-wc-swap-copy]' ) );
+
+	it( 'does nothing when the browser has no Web Animations API', () => {
+		// @ts-expect-error The fake is not part of jsdom.
+		delete HTMLElement.prototype.getAnimations;
+		expect( captureSwap( container, 1 ) ).toBeNull();
+	} );
+
+	it( 'fades out inert copies of the old sections without ids, names, or labels for fields', () => {
+		const snapshot = capture( 1 );
+		switchToPickup();
+		playSwap( snapshot );
+
+		expect( copies() ).toHaveLength( 2 );
+		copies().forEach( ( copy ) => {
+			expect( copy.getAttribute( 'data-wc-swap-copy' ) ).toBe( 'right' );
+			expect( copy.hasAttribute( 'inert' ) ).toBe( true );
+			expect( copy.getAttribute( 'aria-hidden' ) ).toBe( 'true' );
+			expect( copy.id ).toBe( '' );
+			expect( copy.querySelector( '[id], [name], [for]' ) ).toBeNull();
+		} );
+		expect( ( copies()[ 1 ] as HTMLElement ).style.top ).toBe( '250px' );
+		expect( document.getElementById( 'shipping-fields' ) ).toBeNull();
+	} );
+
+	it( 'slides the new sections in from the other side', () => {
+		const snapshot = capture( -1 );
+		const pickup = switchToPickup();
+		playSwap( snapshot );
+
+		expect( pickup.getAttribute( 'data-wc-swap-in' ) ).toBe( 'left' );
+		expect( method.hasAttribute( 'data-wc-swap-in' ) ).toBe( false );
+		expect( pay.hasAttribute( 'data-wc-swap-in' ) ).toBe( false );
+	} );
+
+	it( 'holds the sections after the group in place, also when content loads, until the copies have gone', async () => {
+		// Fake timers run the animation frames in order.
+		jest.useFakeTimers();
+		const snapshot = capture( 1 );
+		const pickup = switchToPickup();
+		playSwap( snapshot );
+
+		expect( topOf( pay ) ).toBe( 350 );
+		expect( pay.style.translate ).toBe( '0 240px' );
+		expect( container.style.height ).toBe( '430px' );
+
+		heights.set( pickup, 120 );
+		jest.advanceTimersByTime( 20 );
+		expect( topOf( pay ) ).toBe( 350 );
+
+		copyFade.finish();
+		await jest.advanceTimersByTimeAsync( 1 );
+		expect( copies() ).toHaveLength( 0 );
+		expect( pay.hasAttribute( 'data-wc-swap-after' ) ).toBe( true );
+		expect( pay.style.translate ).toBe( '' );
+		expect( container.hasAttribute( 'style' ) ).toBe( false );
+	} );
+
+	it( 'changes the layout at once with reduced motion, and only fades the new sections in', async () => {
+		isReducedMotion = true;
+		const snapshot = capture( 1 );
+		const pickup = switchToPickup();
+		playSwap( snapshot );
+
+		expect( copies() ).toHaveLength( 0 );
+		expect( topOf( pay ) ).toBe( 110 );
+		expect( container.hasAttribute( 'style' ) ).toBe( false );
+		expect( pickup.getAttribute( 'data-wc-swap-in' ) ).toBe( 'right' );
+
+		entrance.finish();
+		await flush();
+		[ container, method, pickup, pay ].forEach( ( element ) => {
+			expect(
+				element.getAttributeNames().filter( ( name ) => name !== 'id' )
+			).toEqual( [] );
+		} );
+	} );
+
+	it( 'leaves nothing behind when the motion ends', async () => {
+		const snapshot = capture( 1 );
+		const pickup = switchToPickup();
+		playSwap( snapshot );
+		copyFade.finish();
+		await flush();
+		entrance.finish();
+		await flush();
+
+		expect( copies() ).toHaveLength( 0 );
+		[ container, method, pickup, pay ].forEach( ( element ) => {
+			expect(
+				element.getAttributeNames().filter( ( name ) => name !== 'id' )
+			).toEqual( [] );
+		} );
+	} );
+
+	it( 'releases the hold after a time if the animations never end', () => {
+		jest.useFakeTimers();
+		const snapshot = capture( 1 );
+		const pickup = switchToPickup();
+		playSwap( snapshot );
+		jest.advanceTimersByTime( 1000 );
+
+		expect( copies() ).toHaveLength( 0 );
+		expect( pickup.hasAttribute( 'data-wc-swap-in' ) ).toBe( false );
+		expect( pay.hasAttribute( 'style' ) ).toBe( false );
+		expect( container.hasAttribute( 'data-wc-swapping' ) ).toBe( false );
+		expect( container.hasAttribute( 'style' ) ).toBe( false );
+	} );
+
+	it( 'ends at once for a change that applies immediately, such as after a key press', () => {
+		const snapshot = capture( 1 );
+		const pickup = switchToPickup();
+		playSwap( snapshot );
+		stopSwap( container );
+
+		expect( copies() ).toHaveLength( 0 );
+		[ container, method, pickup, pay ].forEach( ( element ) => {
+			expect(
+				element.getAttributeNames().filter( ( name ) => name !== 'id' )
+			).toEqual( [] );
+		} );
+	} );
+
+	it( 'only ends the slide of the swap, not other animations of the sections after the group', () => {
+		const slide = { transitionProperty: 'translate', cancel: jest.fn() };
+		const themeAnimation = { animationName: 'pulse', cancel: jest.fn() };
+		const getAnimations = HTMLElement.prototype.getAnimations;
+		HTMLElement.prototype.getAnimations = function ( this: HTMLElement ) {
+			return this === pay
+				? ( [ slide, themeAnimation ] as unknown as Animation[] )
+				: getAnimations.call( this );
+		};
+		const snapshot = capture( 1 );
+		switchToPickup();
+		playSwap( snapshot );
+		stopSwap( container );
+
+		expect( slide.cancel ).toHaveBeenCalled();
+		expect( themeAnimation.cancel ).not.toHaveBeenCalled();
+	} );
+
+	it( 'ends at once after a swap turned around, also for the copies of the first swap', () => {
+		const first = capture( 1 );
+		const pickup = switchToPickup();
+		playSwap( first );
+
+		const second = capture( -1 );
+		const newShipping = section( 'shipping-fields', 200 );
+		const newRates = section( 'shipping-option', 100 );
+		pickup.replaceWith( newShipping, newRates );
+		playSwap( second );
+		stopSwap( container );
+
+		expect( copies() ).toHaveLength( 0 );
+		[ container, method, newShipping, newRates, pay ].forEach(
+			( element ) => {
+				expect(
+					element
+						.getAttributeNames()
+						.filter( ( name ) => name !== 'id' )
+				).toEqual( [] );
+			}
+		);
+	} );
+
+	it( 'turns around from the current position, and leaves nothing behind', async () => {
+		const first = capture( 1 );
+		const pickup = switchToPickup();
+		playSwap( first );
+
+		const second = capture( -1 );
+		const newShipping = section( 'shipping-fields', 200 );
+		const newRates = section( 'shipping-option', 100 );
+		pickup.replaceWith( newShipping, newRates );
+		playSwap( second );
+
+		// The sections after the group stay where they were, which is where they are now.
+		expect( topOf( pay ) ).toBe( 350 );
+		expect( pay.style.translate ).toBe( '0 0px' );
+		// The first copies still fade out, and a copy of the pickup section joins them.
+		expect(
+			copies().map( ( copy ) => copy.getAttribute( 'data-wc-swap-copy' ) )
+		).toEqual( [ 'right', 'right', 'left' ] );
+		expect( pickup.hasAttribute( 'data-wc-swap-in' ) ).toBe( false );
+		expect( newShipping.getAttribute( 'data-wc-swap-in' ) ).toBe( 'left' );
+
+		copyFade.finish();
+		await flush();
+		entrance.finish();
+		await flush();
+
+		expect( copies() ).toHaveLength( 0 );
+		[ container, method, newShipping, newRates, pay ].forEach(
+			( element ) => {
+				expect(
+					element
+						.getAttributeNames()
+						.filter( ( name ) => name !== 'id' )
+				).toEqual( [] );
+			}
+		);
+	} );
+} );
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/style.scss b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/style.scss
index c265ae758ab..beff00a416f 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/style.scss
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/style.scss
@@ -105,4 +105,24 @@
 	.wc-block-components-address-form__address_2 {
 		@include motion-collapse;
 	}
+
+	// The sections that Ship or Pickup changes swap as one group, and the form height changes once.
+	.wc-block-checkout__form {
+		// Keeps the margin of the last section inside the form. Otherwise it collapses through the form at rest, but
+		// not while the form has a set height, and the content below jumps by that margin.
+		display: flow-root;
+		@include motion-collapse;
+		@include motion-swap;
+
+		// The sections after the group slide with the height, so nothing needs a clip. Content that loads while
+		// the height changes stays visible.
+		&[data-wc-collapse] {
+			clip-path: none;
+		}
+
+		// A copy is after all the sections, so its step number counts on from the last one.
+		> [data-wc-swap-copy] .wc-block-components-checkout-step__title::before {
+			visibility: hidden;
+		}
+	}
 }
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/block.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/block.tsx
index 5d6a50a7321..2859f86f69b 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/block.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/block.tsx
@@ -5,10 +5,19 @@ import { __ } from '@wordpress/i18n';
 import { useShippingData } from '@woocommerce/base-context/hooks';
 import clsx from 'clsx';
 import { Icon, store, shipping } from '@wordpress/icons';
-import { useEffect } from '@wordpress/element';
+import {
+	useEffect,
+	useLayoutEffect,
+	useRef,
+	useState,
+} from '@wordpress/element';
+import type { CSSProperties, MouseEvent } from 'react';
 import { cartStore, validationStore } from '@woocommerce/block-data';
 import { useDispatch, useSelect } from '@wordpress/data';
-import { isPackageRateCollectable } from '@woocommerce/base-utils';
+import {
+	isPackageRateCollectable,
+	whenAnimationsEnd,
+} from '@woocommerce/base-utils';
 import { getSetting } from '@woocommerce/settings';
 import { Button } from '@ariakit/react';
 import { shippingAddressHasValidationErrors } from '@woocommerce/block-data/cart/utils';
@@ -40,7 +49,7 @@ const LocalPickupSelector = ( {
 	showIcon: boolean;
 	toggleText: string;
 	multiple: boolean;
-	onClick: () => void;
+	onClick: ( event: MouseEvent ) => void;
 } ) => {
 	return (
 		<Button
@@ -90,7 +99,7 @@ const ShippingSelector = ( {
 	showPrice: boolean;
 	showIcon: boolean;
 	shippingCostRequiresAddress: boolean;
-	onClick: () => void;
+	onClick: ( event: MouseEvent ) => void;
 	toggleText: string;
 } ) => {
 	const hasShippableRates = useSelect( ( select ) => {
@@ -168,7 +177,11 @@ const Block = ( {
 	shippingText,
 }: {
 	checked: string;
-	onChange: ( value: string ) => void;
+	/**
+	 * Called when the shopper chooses an option. `direction` is the way that the selection slides on the screen: 1 to
+	 * the right, -1 to the left. It is 0 when the change applies immediately, such as after a key press.
+	 */
+	onChange: ( value: string, direction: number ) => void;
 	showPrice: boolean;
 	showIcon: boolean;
 	localPickupText: string;
@@ -184,8 +197,78 @@ const Block = ( {
 		localPickupText || defaultLocalPickupText
 	);

+	const containerRef = useRef< HTMLDivElement >( null );
+	const indicatorRef = useRef< HTMLSpanElement >( null );
+	const [ indicator, setIndicator ] = useState< {
+		key: number;
+		isVertical: boolean;
+		style: CSSProperties;
+	} | null >( null );
+
+	// The indicator only exists while it slides. Without motion, it goes before paint.
+	useLayoutEffect(
+		() =>
+			indicator
+				? whenAnimationsEnd( indicatorRef.current, () =>
+						setIndicator( null )
+					)
+				: undefined,
+		[ indicator ]
+	);
+
+	// The selected style slides from the old option to the new one, or from where it is if it still slides. A click
+	// that a key press starts has no click count, and applies immediately.
+	const select = ( value: string, event: MouseEvent ) => {
+		if ( value === checked ) {
+			onChange( value, 0 );
+			return;
+		}
+		const container = containerRef.current;
+		// Ship renders first, then Pickup.
+		const options = container?.querySelectorAll(
+			'.wc-block-checkout__shipping-method-option'
+		);
+		const to = options?.[ value === 'pickup' ? 1 : 0 ];
+		const from =
+			indicatorRef.current ?? options?.[ value === 'pickup' ? 0 : 1 ];
+		if ( event.detail === 0 || ! container || ! to || ! from ) {
+			setIndicator( null );
+			onChange( value, 0 );
+			return;
+		}
+		const box = container.getBoundingClientRect();
+		const toRect = to.getBoundingClientRect();
+		const fromRect = from.getBoundingClientRect();
+		const x =
+			fromRect.left + fromRect.width / 2 - toRect.left - toRect.width / 2;
+		const y =
+			fromRect.top + fromRect.height / 2 - toRect.top - toRect.height / 2;
+		setIndicator( ( current ) => ( {
+			key: ( current?.key ?? 0 ) + 1,
+			isVertical: Math.abs( y ) > Math.abs( x ),
+			style: {
+				left: toRect.left - box.left - container.clientLeft,
+				top: toRect.top - box.top - container.clientTop,
+				width: toRect.width,
+				height: toRect.height,
+				'--wc-shipping-method-indicator-offset': `${ x }px ${ y }px`,
+				// An indicator that turns around keeps its current stretch, so its size does not jump.
+				'--wc-shipping-method-indicator-from-scale': `${
+					fromRect.width / toRect.width
+				} ${ fromRect.height / toRect.height }`,
+			} as CSSProperties,
+		} ) );
+		// The way the selection moves. When the options stack, Pickup counts as to the right of Ship.
+		const stackedDirection = value === 'pickup' ? 1 : -1;
+		onChange(
+			value,
+			Math.abs( x ) >= 1 ? Math.sign( -x ) : stackedDirection
+		);
+	};
+
 	return (
 		<div
+			ref={ containerRef }
 			id="shipping-method"
 			// components-button-group is here for backwards compatibility, in case themes or plugins rely on it.
 			className="components-button-group wc-block-checkout__shipping-method-container"
@@ -194,9 +277,7 @@ const Block = ( {
 		>
 			<ShippingSelector
 				checked={ checked }
-				onClick={ () => {
-					onChange( 'shipping' );
-				} }
+				onClick={ ( event ) => select( 'shipping', event ) }
 				rate={ getShippingPrices( shippingRates[ 0 ]?.shipping_rates ) }
 				showPrice={ showPrice }
 				showIcon={ showIcon }
@@ -205,9 +286,7 @@ const Block = ( {
 			/>
 			<LocalPickupSelector
 				checked={ checked }
-				onClick={ () => {
-					onChange( 'pickup' );
-				} }
+				onClick={ ( event ) => select( 'pickup', event ) }
 				rate={ getLocalPickupPrices(
 					shippingRates[ 0 ]?.shipping_rates
 				) }
@@ -216,6 +295,21 @@ const Block = ( {
 				showIcon={ showIcon }
 				toggleText={ localPickupTextFromSettings }
 			/>
+			{ indicator && (
+				<span
+					key={ indicator.key }
+					ref={ indicatorRef }
+					aria-hidden="true"
+					className={ clsx(
+						'wc-block-checkout__shipping-method-indicator',
+						{
+							'wc-block-checkout__shipping-method-indicator--vertical':
+								indicator.isVertical,
+						}
+					) }
+					style={ indicator.style }
+				/>
+			) }
 		</div>
 	);
 };
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/frontend.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/frontend.tsx
index 6aeeef1ebe1..4655c77b873 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/frontend.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/frontend.tsx
@@ -10,13 +10,20 @@ import {
 	cartStore,
 } from '@woocommerce/block-data';
 import { useShippingData } from '@woocommerce/base-context/hooks';
-import { hasCollectableRate } from '@woocommerce/base-utils';
+import {
+	captureSwap,
+	hasCollectableRate,
+	playSwap,
+	stopSwap,
+	type SwapSnapshot,
+} from '@woocommerce/base-utils';
 import {
 	LOCAL_PICKUP_ENABLED,
 	SHIPPING_METHODS_EXIST,
 	SHIPPING_ENABLED,
 } from '@woocommerce/block-settings';
 import { useCheckoutBlockContext } from '@woocommerce/blocks/checkout/context';
+import { useLayoutEffect, useRef } from '@wordpress/element';

 /**
  * Internal dependencies
@@ -58,6 +65,15 @@ const FrontendBlock = ( {
 	const { selectShippingRate } = useDispatch( cartStore );
 	const { needsShipping, isCollectable, shippingRates } = useShippingData();

+	// The sections below the toggle swap as one movement, the way that the selection moved, before paint.
+	const swapRef = useRef< SwapSnapshot | null >( null );
+	useLayoutEffect( () => {
+		if ( swapRef.current ) {
+			playSwap( swapRef.current );
+			swapRef.current = null;
+		}
+	}, [ prefersCollection ] );
+
 	// Note that display logic is also found in plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/register-components.ts
 	// where the block is not registered if the conditions are not met.
 	if (
@@ -70,7 +86,16 @@ const FrontendBlock = ( {
 		return null;
 	}

-	const onChange = ( method: string ) => {
+	const onChange = ( method: string, direction: number ) => {
+		// The form, whose children are the sections.
+		const sections =
+			document.getElementById( 'shipping-method' )?.parentElement ?? null;
+		const isChange = ( method === 'pickup' ) !== prefersCollection;
+		swapRef.current =
+			isChange && direction ? captureSwap( sections, direction ) : null;
+		if ( isChange && ! direction ) {
+			stopSwap( sections );
+		}
 		if ( method === 'pickup' ) {
 			void setPrefersCollection( true );
 		} else {
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/style.scss b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/style.scss
index f5ed96b16d9..c37bfe81446 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/style.scss
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/style.scss
@@ -53,6 +53,62 @@ $component-background-hover: color-mix(in srgb, currentColor 12%, transparent);
 	}
 }

+// While the selection slides, the indicator shows the selected style, behind the content of the options.
+:where(.wp-block-woocommerce-checkout) {
+	.wc-block-checkout__shipping-method-container:has(> .wc-block-checkout__shipping-method-indicator) {
+		position: relative;
+		isolation: isolate;
+
+		.wc-block-checkout__shipping-method-option--selected {
+			border-color: transparent;
+			background: transparent;
+		}
+	}
+
+	.wc-block-checkout__shipping-method-indicator {
+		// It stretches a little along its path, and keeps its area.
+		$stretch: 1.12;
+		--wc-shipping-method-indicator-stretch: #{$stretch} calc(1 / #{$stretch});
+		position: absolute;
+		z-index: -1;
+		box-sizing: border-box;
+		border: 2px solid currentColor;
+		border-radius: $universal-border-radius;
+		background: $input-background-light;
+		pointer-events: none;
+
+		@include motion-safe {
+			animation:
+				wc-shipping-method-indicator-move motion-duration(lg) motion-easing(balanced),
+				wc-shipping-method-indicator-stretch motion-duration(lg) motion-easing(balanced);
+		}
+
+		&--vertical {
+			--wc-shipping-method-indicator-stretch: calc(1 / #{$stretch}) #{$stretch};
+		}
+	}
+}
+
+.has-dark-controls .wc-block-checkout__shipping-method-indicator {
+	background: $input-background-dark;
+}
+
+@keyframes wc-shipping-method-indicator-move {
+	from {
+		translate: var(--wc-shipping-method-indicator-offset);
+	}
+}
+
+@keyframes wc-shipping-method-indicator-stretch {
+	from {
+		scale: var(--wc-shipping-method-indicator-from-scale, 1);
+	}
+
+	50% {
+		scale: var(--wc-shipping-method-indicator-stretch);
+	}
+}
+
 .wc-block-checkout__shipping-method-option-title-wrapper {
 	display: flex;
 	flex-direction: row;
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/test/block.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/test/block.tsx
index 6f56b23df05..08dfda36c85 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/test/block.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/test/block.tsx
@@ -1,7 +1,7 @@
 /**
  * External dependencies
  */
-import { render, screen, act } from '@testing-library/react';
+import { render, screen, act, fireEvent } from '@testing-library/react';
 import { dispatch } from '@wordpress/data';
 import { cartStore, validationStore } from '@woocommerce/block-data';

@@ -67,17 +67,20 @@ const collectionRate = generateShippingRate( {
  * @param options.addressIncomplete   Whether the shipping address still has a validation error.
  * @param options.offers              The rates the one package comes back with.
  * @param options.showPrice           Whether the block is set to show prices.
+ * @param options.onChange            Called when the shopper chooses an option.
  */
 const renderWith = ( {
 	costRequiresAddress = false,
 	addressIncomplete = false,
 	offers,
 	showPrice = true,
+	onChange = () => void 0,
 }: {
 	costRequiresAddress?: boolean;
 	addressIncomplete?: boolean;
 	offers: ReturnType< typeof generateShippingRate >[];
 	showPrice?: boolean;
+	onChange?: ( value: string, direction: number ) => void;
 } ) => {
 	mockShippingCostRequiresAddress = costRequiresAddress;

@@ -100,7 +103,7 @@ const renderWith = ( {
 	return render(
 		<Block
 			localPickupText="backup local pickup text"
-			onChange={ () => void 0 }
+			onChange={ onChange }
 			showIcon={ false }
 			showPrice={ showPrice }
 			checked={ 'shipping' }
@@ -168,3 +171,130 @@ describe( 'Block', () => {
 		).toHaveTextContent( 'calculated with an address' );
 	} );
 } );
+
+describe( 'Choosing an option', () => {
+	const pickupOption = () =>
+		screen.getByRole( 'radio', {
+			name: ( name: string ) =>
+				name.startsWith( 'Pickup text from settings' ),
+		} );
+	const shipOption = () =>
+		screen.getByRole( 'radio', {
+			name: ( name: string ) => name.startsWith( 'backup shipping text' ),
+		} );
+
+	afterEach( () => {
+		jest.restoreAllMocks();
+		// @ts-expect-error The fake is not part of jsdom.
+		delete HTMLElement.prototype.getAnimations;
+	} );
+
+	it( 'slides the selection the way it moves on the screen, also right to left, and leaves nothing behind', () => {
+		const onChange = jest.fn();
+		const { container } = renderWith( {
+			offers: [ deliveryRate, collectionRate ],
+			onChange,
+		} );
+		// Right to left: Pickup is to the left of Ship.
+		const pickup = pickupOption();
+		jest.spyOn(
+			Element.prototype,
+			'getBoundingClientRect'
+		).mockImplementation( function ( this: Element ) {
+			return {
+				left: this === pickup ? 0 : 200,
+				top: 0,
+				width: 200,
+				height: 50,
+			} as DOMRect;
+		} );
+
+		fireEvent.click( pickup, { detail: 1 } );
+
+		expect( onChange ).toHaveBeenCalledWith( 'pickup', -1 );
+		// Without the Web Animations API, the indicator goes before paint.
+		expect(
+			container.querySelector(
+				'.wc-block-checkout__shipping-method-indicator'
+			)
+		).not.toBeInTheDocument();
+	} );
+
+	it( 'turns the selection around at its current size', () => {
+		const indicatorClass = 'wc-block-checkout__shipping-method-indicator';
+		// The indicator slides until the test ends.
+		HTMLElement.prototype.getAnimations = function ( this: HTMLElement ) {
+			return this.classList.contains( indicatorClass )
+				? [
+						{
+							playState: 'running',
+							finished: new Promise( () => undefined ),
+							effect: {
+								getComputedTiming: () => ( { endTime: 400 } ),
+							},
+						} as unknown as Animation,
+					]
+				: [];
+		};
+		const { container, rerender } = renderWith( {
+			offers: [ deliveryRate, collectionRate ],
+		} );
+		const pickup = pickupOption();
+		jest.spyOn(
+			Element.prototype,
+			'getBoundingClientRect'
+		).mockImplementation( function ( this: Element ) {
+			// Halfway, the indicator is stretched 224px by 40px.
+			if ( this.classList.contains( indicatorClass ) ) {
+				return { left: 88, top: 5, width: 224, height: 40 } as DOMRect;
+			}
+			return {
+				left: this === pickup ? 200 : 0,
+				top: 0,
+				width: 200,
+				height: 50,
+			} as DOMRect;
+		} );
+
+		fireEvent.click( pickup, { detail: 1 } );
+		rerender(
+			<Block
+				localPickupText="backup local pickup text"
+				onChange={ () => void 0 }
+				showIcon={ false }
+				showPrice
+				checked={ 'pickup' }
+				shippingText="backup shipping text"
+			/>
+		);
+		fireEvent.click( shipOption(), { detail: 1 } );
+
+		const indicator = container.querySelector(
+			`.${ indicatorClass }`
+		) as HTMLElement;
+		expect(
+			indicator.style.getPropertyValue(
+				'--wc-shipping-method-indicator-from-scale'
+			)
+		).toBe( '1.12 0.8' );
+	} );
+
+	it( 'applies a key press immediately', () => {
+		const onChange = jest.fn();
+		renderWith( { offers: [ deliveryRate, collectionRate ], onChange } );
+
+		// A click that a key press starts has no click count.
+		fireEvent.click( pickupOption(), { detail: 0 } );
+
+		expect( onChange ).toHaveBeenCalledWith( 'pickup', 0 );
+	} );
+
+	it( 'does not slide when the shopper chooses the selected option', () => {
+		const onChange = jest.fn();
+		renderWith( { offers: [ deliveryRate, collectionRate ], onChange } );
+
+		fireEvent.click( shipOption(), { detail: 1 } );
+
+		expect( onChange ).toHaveBeenCalledWith( 'shipping', 0 );
+	} );
+} );
diff --git a/plugins/woocommerce/client/blocks/docs/contributors/motion.md b/plugins/woocommerce/client/blocks/docs/contributors/motion.md
index df3c10b8075..243a3cc7765 100644
--- a/plugins/woocommerce/client/blocks/docs/contributors/motion.md
+++ b/plugins/woocommerce/client/blocks/docs/contributors/motion.md
@@ -76,11 +76,12 @@ Use the helpers in `assets/css/abstracts/_motion.scss`. Do not write `transition
 | `@include motion-transition( $state, $move, $duration, $easing )` | A state change and movement. `$move` runs over `$duration` (default `lg`), only when motion is allowed. | `@include motion-transition( $state: opacity, $move: translate );` |
 | `motion-hold( … )` | Keeps a property, such as `visibility`, at its old value until a fade ends. | `transition: motion-state( opacity ), motion-hold( visibility );` |
 | `@include motion-enter( $keyframes, $duration, $delay )` | Content that appears. It fades in, and plays `$keyframes` (default `wc-rise`). | `@include motion-enter( wc-grow, md );` |
-| `@include motion-exit( $keyframes )` | Content that goes. It fades out over 200ms and keeps the end state until it unmounts. | `@include motion-exit( wc-shrink );` |
+| `@include motion-exit( $keyframes, $duration )` | Content that goes. It fades out over `$duration` (default `md`) and keeps the end state until it unmounts. | `@include motion-exit( wc-shrink );` |
 | `@include motion-stagger( $keyframes )` | Sibling rows that enter 50ms apart. It counts rows with `sibling-index()`, and with `nth-child` in browsers that do not have it. | `@include motion-stagger;` |
 | `@include motion-fade-in` / `motion-fade-out` | A fade with no movement. | |
 | `@include motion-dim( $states )` | Dims the element while `$states` matches, such as `".is-disabled"`. | Cart rows, disabled radios |
 | `@include motion-collapse` | The timing for `animateCollapse`. The content grows over 300ms and collapses over 200ms, and fades. With reduced motion, it only fades. | `Panel` content |
+| `@include motion-swap` | The timing for `playSwap`, on the element whose children are the sections. Old sections fade out over 100ms, and new sections fade in and slide in after them. With reduced motion, the layout changes at once and the new sections fade in. Use it with `motion-collapse`. | The Checkout form |
 | `@include motion-safe { … }` | Movement that the other helpers do not cover. | |

 `assets/css/style.scss` has the shared keyframes. `wc-fade-in` and `wc-fade-out` only fade. `wc-rise`, `wc-grow`, and `wc-shrink` move with `translate`, `scale`, and `filter`, so they combine with a fade and with the resting `transform` of an element.
@@ -96,6 +97,7 @@ Motion that changes the layout runs in JavaScript, because it must measure sizes
 | `animateCollapse( element, isOpen, animate, from )` (`@woocommerce/base-utils`) | Grows `element` open or collapses it shut in the real layout, and turns around if it still moves. Give `element` the `motion-collapse` mixin. Use it through `usePresence` when the component owns the content. Pass `from`, such as `{ height: '20px' }`, to grow from the size of the content that `element` replaces, or to change the height of an element that stays. |
 | `collapseCopy( element )` (`@woocommerce/base-utils`) | Collapses an inert copy of `element` in its place, so that `element` can unmount at once. Call it just before `element` unmounts. If `element` grows again first, it grows from the copy. |
 | `useToggleCollapse( isShown, getElement, { growFromTrigger } )` (`@woocommerce/base-hooks`) | Content that a control shows and hides, such as a checkbox that reveals a field. Call the `onToggle` that it returns in the handler of the control, before the state changes. Pass it the click event if there is one, or else put `triggerRef` on the control. `getElement` must not return the copy, which keeps the element's classes: find the element by id, or skip `[data-wc-collapse-copy]`. After a click, the element grows in, or an inert copy of it collapses while the real element unmounts. After a key press, the change applies immediately. Pass `growFromTrigger: true` when the content replaces the control, to grow from the height of the control. |
+| `captureSwap( container, direction )` and `playSwap( snapshot )` (`@woocommerce/base-utils`) | Swap the group of sections that a choice changes as one movement. Call `captureSwap` in the event handler, before the change, with the way that the selection moved on the screen (1 to the right, -1 to the left). Call `playSwap` in a layout effect after the sections change. Inert copies of the old sections fade out, the sections after the group hold their place until the copies have gone, and then everything moves one time. A new swap continues from the current position. |
 | `useOrderSummaryRow( cart, isShown )` (`@woocommerce/base-context/hooks`) | An order summary row that only shows sometimes, such as Fees. The row appears and goes when the skeletons end, and grows and collapses through `usePresence`. Rows of the cart that loads with the page show immediately. It returns `{ cart, isStale, wrapperProps }`. Render the row from `cart` while it is not `null`, and spread `wrapperProps` on its `TotalsWrapper`. `isStale` is true while `cart` is not the current cart, so disable controls in the row then. |

 ## Techniques
@@ -116,6 +118,8 @@ Find the change in this table, and use the helpers above.
 | A toast or snackbar appears and goes | It rises in and drops out. |
 | Content appears or goes and moves the content below, such as a panel, notice, field error, or section | It grows and collapses in the real layout. It stays mounted while it goes. |
 | A form or its fields go | The real form unmounts at once, so its fields stop counting. An inert copy collapses in its place. |
+| The selection moves to another option, such as Ship or Pickup | A copy of the selected style slides to the new option, and stretches a little on the way. |
+| A choice swaps a group of sections, such as Ship or Pickup | The old sections fade out and move 24px the way that the selection moved. Then the new sections fade in and slide in from the other side. The sections after them hold their place until the old sections have gone, then move one time. With reduced motion, the layout changes at once, and the new sections fade in. |
 | An element becomes a different view of itself, such as an address card that becomes its form | The two views crossfade while the height changes. |
 | A table row goes | It fades in place, and the rows below slide up. |