1e41f4b71Sopenharmony_ci# Shared Element Transition (sharedTransition)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciA shared element transition is a transition animation applied to a component that is present on two pages. This component is called the shared element and can be set in the **sharedTransition** attribute.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Attributes
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci| Name            | Type         | Mandatory                                   | Description                                                    |
14e41f4b71Sopenharmony_ci| ---------------- | -----------------|------------------------------------------- | ------------------------------------------------------------ |
15e41f4b71Sopenharmony_ci|      id          |  string         | Yes                                        |    Transition of the shared element. If the same **id** value is configured for a component on the two pages, this component is considered as a shared element of the pages. If the **id** value is an empty string, no transition will be applied to the component.|
16e41f4b71Sopenharmony_ci|     options          |  [sharedTransitionOptions](#sharedtransitionoptions)       | No    |  Parameters of the shared element transition animation.|
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci> **NOTE**
19e41f4b71Sopenharmony_ci>
20e41f4b71Sopenharmony_ci> **motionPath** is effective only when **type** is set to **SharedTransitionEffectType.Exchange**.
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci## sharedTransitionOptions
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci| Name             | Type     | Mandatory      | Description                                                     |
27e41f4b71Sopenharmony_ci| ----------------- | -------------|-------------- | --------------------------------------------------------------|
28e41f4b71Sopenharmony_ci| duration          |     number   |  No          | Animation duration.<br>Default value: **1000**<br>Unit: ms|
29e41f4b71Sopenharmony_ci| curve             |      [Curve](ts-appendix-enums.md#curve) \| string \| [ICurve](../js-apis-curve.md#icurve9)<sup>10+</sup>  | No| Animation curve.<br>Default value: **Curve.Linear**|
30e41f4b71Sopenharmony_ci| delay          |     number   |  No          | Delay of animation playback.<br>Default value: **0**<br>Unit: ms|
31e41f4b71Sopenharmony_ci| motionPath          | [MotionPathOptions](./ts-motion-path-animation.md)  |  No          | Motion path.|
32e41f4b71Sopenharmony_ci| zIndex          |     number   |  No             | Z-axis.|
33e41f4b71Sopenharmony_ci| type           |     [SharedTransitionEffectType](ts-appendix-enums.md#sharedtransitioneffecttype)   |  No  | Animation type.<br>Default value: **SharedTransitionEffectType.Exchange**|
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci## Example
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ciThis example implements the custom transition of a shared image during redirection from one page to another, which is triggered by a click on the image.
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci```ts
41e41f4b71Sopenharmony_ci// xxx.ets
42e41f4b71Sopenharmony_ci@Entry
43e41f4b71Sopenharmony_ci@Component
44e41f4b71Sopenharmony_cistruct SharedTransitionExample {
45e41f4b71Sopenharmony_ci  @State active: boolean = false
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci  build() {
48e41f4b71Sopenharmony_ci    Column() {
49e41f4b71Sopenharmony_ci      Navigator({ target: 'pages/PageB', type: NavigationType.Push }) {
50e41f4b71Sopenharmony_ci        Image($r('app.media.ic_health_heart')).width(50).height(50)
51e41f4b71Sopenharmony_ci          .sharedTransition('sharedImage', { duration: 800, curve: Curve.Linear, delay: 100 })
52e41f4b71Sopenharmony_ci      }.padding({ left: 20, top: 20 })
53e41f4b71Sopenharmony_ci      .onClick(() => {
54e41f4b71Sopenharmony_ci        this.active = true
55e41f4b71Sopenharmony_ci      })
56e41f4b71Sopenharmony_ci    }
57e41f4b71Sopenharmony_ci  }
58e41f4b71Sopenharmony_ci}
59e41f4b71Sopenharmony_ci```
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci```ts
62e41f4b71Sopenharmony_ci// PageB.ets
63e41f4b71Sopenharmony_ci@Entry
64e41f4b71Sopenharmony_ci@Component
65e41f4b71Sopenharmony_cistruct pageBExample {
66e41f4b71Sopenharmony_ci  build() {
67e41f4b71Sopenharmony_ci    Stack() {
68e41f4b71Sopenharmony_ci      Image($r('app.media.ic_health_heart')).width(150).height(150)
69e41f4b71Sopenharmony_ci        .sharedTransition('sharedImage', { duration: 800, curve: Curve.Linear, delay: 100 })
70e41f4b71Sopenharmony_ci    }.width('100%').height('100%')
71e41f4b71Sopenharmony_ci  }
72e41f4b71Sopenharmony_ci}
73e41f4b71Sopenharmony_ci```
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci![shared](figures/shared.gif)
76