1e41f4b71Sopenharmony_ci# tspan
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **\<tspan>** component is used to add a text style.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci>  **NOTE**
7e41f4b71Sopenharmony_ci>  - This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci>  - This component can have **\<tspan>** child components nested.
10e41f4b71Sopenharmony_ci>
11e41f4b71Sopenharmony_ci>  - This component can only be nested by the parent element label **svg**.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci## Required Permissions
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ciNone
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci## Child Components
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ciThe **[\<tspan>](js-components-svg-tspan.md)** child component is supported.
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ciThe attributes in the following table are supported.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci| Name            | Type                                | Default Value  | Mandatory  | Description                                      |
27e41f4b71Sopenharmony_ci| -------------- | ---------------------------------- | ----- | ---- | ---------------------------------------- |
28e41f4b71Sopenharmony_ci| id             | string                             | -     | No   | Unique ID of the component.                                |
29e41f4b71Sopenharmony_ci| x              | &lt;length&gt;\|&lt;percentage&gt; | 0     | No   | X-coordinate of the upper left corner of the component.                            |
30e41f4b71Sopenharmony_ci| y              | &lt;length&gt;\|&lt;percentage&gt; | 0     | No   | Y-coordinate of the upper left corner of the component. This attribute is invalid when the component is a child component of the **\<textpath>**.           |
31e41f4b71Sopenharmony_ci| dx             | &lt;length&gt;\|&lt;percentage&gt; | 0     | No   | Offset of the text on the x-axis.                               |
32e41f4b71Sopenharmony_ci| dy             | &lt;length&gt;\|&lt;percentage&gt; | 0     | No   | Offset of the text on the y-axis. This attribute is invalid when the component is a child component of the **\<textpath>**.              |
33e41f4b71Sopenharmony_ci| rotate         | number                             | 0     | No   | Rotation of the text around its lower left corner. A positive number indicates clockwise rotation, and a negative number indicates counterclockwise rotation.              |
34e41f4b71Sopenharmony_ci| font-size      | &lt;length&gt;                     | 30px  | No   | Font size.                                |
35e41f4b71Sopenharmony_ci| fill           | &lt;color&gt;                      | black | No   | Fill color of the text.                                 |
36e41f4b71Sopenharmony_ci| opacity        | number                             | 1     | No   | Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent. Attribute animations are supported.|
37e41f4b71Sopenharmony_ci| fill-opacity   | number                             | 1.0   | No   | Fill opacity of the text.                                |
38e41f4b71Sopenharmony_ci| stroke         | &lt;color&gt;                      | black | No   | Stroke color.                            |
39e41f4b71Sopenharmony_ci| stroke-width   | number                             | 1px   | No   | Stroke width.                                 |
40e41f4b71Sopenharmony_ci| stroke-opacity | number                             | 1.0   | No   | Stroke opacity.                                |
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci## Example
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci```html
45e41f4b71Sopenharmony_ci<!-- xxx.hml -->
46e41f4b71Sopenharmony_ci<div class="container">
47e41f4b71Sopenharmony_ci  <svg >
48e41f4b71Sopenharmony_ci    <text x="20" y="500" fill="#D2691E" font-size="20">
49e41f4b71Sopenharmony_ci      zero text.
50e41f4b71Sopenharmony_ci      <tspan>first span.</tspan>
51e41f4b71Sopenharmony_ci      <tspan fill="red" font-size="35">second span.</tspan>
52e41f4b71Sopenharmony_ci      <tspan fill="#D2691E" font-size="40" rotate="10">third span.</tspan>
53e41f4b71Sopenharmony_ci    </text>
54e41f4b71Sopenharmony_ci    <text x="20" y="550" fill="#D2691E" font-size="20">
55e41f4b71Sopenharmony_ci      <tspan dx="-5" fill-opacity="0.2">first span.</tspan>
56e41f4b71Sopenharmony_ci      <tspan dx="5" fill="red" font-size="25" fill-opacity="0.4">second span.</tspan>
57e41f4b71Sopenharmony_ci      <tspan dy="-5" fill="#D2691E" font-size="35" rotate="-10" fill-opacity="0.6">third span.</tspan>
58e41f4b71Sopenharmony_ci      <tspan fill="#blue" font-size="40" rotate="10" fill-opacity="0.8" stroke="#00FF00" stroke-width="1px">forth span.</tspan>
59e41f4b71Sopenharmony_ci    </text>
60e41f4b71Sopenharmony_ci  </svg>
61e41f4b71Sopenharmony_ci</div>
62e41f4b71Sopenharmony_ci```
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci```css
65e41f4b71Sopenharmony_ci/* xxx.css */
66e41f4b71Sopenharmony_ci.container {    
67e41f4b71Sopenharmony_ci    flex-direction: row;
68e41f4b71Sopenharmony_ci    justify-content: flex-start;
69e41f4b71Sopenharmony_ci    align-items: flex-start;
70e41f4b71Sopenharmony_ci    height: 1000px;
71e41f4b71Sopenharmony_ci    width: 1080px;
72e41f4b71Sopenharmony_ci}
73e41f4b71Sopenharmony_ci```
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci![tspan-part1](figures/tspan-part1.png)
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ciAttribute animation example
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci```html
80e41f4b71Sopenharmony_ci<!-- xxx.hml -->
81e41f4b71Sopenharmony_ci<div class="container">
82e41f4b71Sopenharmony_ci  <svg>
83e41f4b71Sopenharmony_ci    <text y="300" font-size="30" fill="blue">
84e41f4b71Sopenharmony_ci      <tspan>
85e41f4b71Sopenharmony_ci        tspan attribute x|opacity|rotate
86e41f4b71Sopenharmony_ci        <animate attributeName="x" from="-100" to="400" dur="3s" repeatCount="indefinite"></animate>
87e41f4b71Sopenharmony_ci        <animate attributeName="opacity" from="0.01" to="0.99" dur="3s" repeatCount="indefinite"></animate>
88e41f4b71Sopenharmony_ci        <animate attributeName="rotate" from="0" to="360" dur="3s" repeatCount="indefinite"></animate>
89e41f4b71Sopenharmony_ci      </tspan>
90e41f4b71Sopenharmony_ci    </text>
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci    <text y="350" font-size="30" fill="blue">
93e41f4b71Sopenharmony_ci      <tspan>
94e41f4b71Sopenharmony_ci        tspan attribute dx
95e41f4b71Sopenharmony_ci        <animate attributeName="dx" from="-100" to="400" dur="3s" repeatCount="indefinite"></animate>
96e41f4b71Sopenharmony_ci      </tspan>
97e41f4b71Sopenharmony_ci    </text>
98e41f4b71Sopenharmony_ci  </svg>
99e41f4b71Sopenharmony_ci</div>
100e41f4b71Sopenharmony_ci```
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci```css
103e41f4b71Sopenharmony_ci/* xxx.css */
104e41f4b71Sopenharmony_ci.container {
105e41f4b71Sopenharmony_ci    flex-direction: row;
106e41f4b71Sopenharmony_ci    justify-content: flex-start;
107e41f4b71Sopenharmony_ci    align-items: flex-start;
108e41f4b71Sopenharmony_ci    height: 3000px;
109e41f4b71Sopenharmony_ci    width: 1080px;
110e41f4b71Sopenharmony_ci}
111e41f4b71Sopenharmony_ci```
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci![tspan-animate-part1](figures/tspan-animate-part1.gif)
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci```html
116e41f4b71Sopenharmony_ci<!-- xxx.hml -->
117e41f4b71Sopenharmony_ci<div class="container">
118e41f4b71Sopenharmony_ci  <svg>
119e41f4b71Sopenharmony_ci    <text>
120e41f4b71Sopenharmony_ci      <tspan x="0" y="550" font-size="30">
121e41f4b71Sopenharmony_ci        tspan attribute fill|fill-opacity
122e41f4b71Sopenharmony_ci        <animate attributeName="fill" from="blue" to="red" dur="3s" repeatCount="indefinite"></animate>
123e41f4b71Sopenharmony_ci        <animate attributeName="fill-opacity" from="0.01" to="0.99" dur="3s" repeatCount="indefinite"></animate>
124e41f4b71Sopenharmony_ci      </tspan>
125e41f4b71Sopenharmony_ci    </text>
126e41f4b71Sopenharmony_ci  </svg>
127e41f4b71Sopenharmony_ci</div>
128e41f4b71Sopenharmony_ci```
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci![tspan-animate-part2](figures/tspan-animate-part2.gif)
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci```html
133e41f4b71Sopenharmony_ci<!-- xxx.hml -->
134e41f4b71Sopenharmony_ci<div class="container">
135e41f4b71Sopenharmony_ci  <svg>
136e41f4b71Sopenharmony_ci     <text>
137e41f4b71Sopenharmony_ci       <tspan x="20" y="600" fill="red">
138e41f4b71Sopenharmony_ci         tspan attribute font-size
139e41f4b71Sopenharmony_ci         <animate attributeName="font-size" from="10" to="50" dur="3s" repeatCount="indefinite"></animate>
140e41f4b71Sopenharmony_ci       </tspan>
141e41f4b71Sopenharmony_ci    </text>
142e41f4b71Sopenharmony_ci  </svg>
143e41f4b71Sopenharmony_ci</div>
144e41f4b71Sopenharmony_ci```
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci![tspan-animate-part3](figures/tspan-animate-part3.gif)
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci```html
149e41f4b71Sopenharmony_ci<!-- xxx.hml -->
150e41f4b71Sopenharmony_ci<div class="container">
151e41f4b71Sopenharmony_ci  <svg>
152e41f4b71Sopenharmony_ci    <text>
153e41f4b71Sopenharmony_ci      <tspan x="20" y="650" font-size="25" fill="blue" stroke="red">
154e41f4b71Sopenharmony_ci        tspan attribute stroke
155e41f4b71Sopenharmony_ci        <animate attributeName="stroke" from="red" to="#00FF00" dur="3s" repeatCount="indefinite"></animate>
156e41f4b71Sopenharmony_ci      </tspan>
157e41f4b71Sopenharmony_ci    </text>
158e41f4b71Sopenharmony_ci    <text>
159e41f4b71Sopenharmony_ci      <tspan x="300" y="650" font-size="25" fill="white" stroke="red">
160e41f4b71Sopenharmony_ci        tspan attribute stroke-width-opacity
161e41f4b71Sopenharmony_ci        <animate attributeName="stroke-width" from="1" to="5" dur="3s" repeatCount="indefinite"></animate>
162e41f4b71Sopenharmony_ci        <animate attributeName="stroke-opacity" from="0.01" to="0.99" dur="3s" repeatCount="indefinite"></animate>
163e41f4b71Sopenharmony_ci      </tspan>
164e41f4b71Sopenharmony_ci    </text>
165e41f4b71Sopenharmony_ci  </svg>
166e41f4b71Sopenharmony_ci</div>
167e41f4b71Sopenharmony_ci```
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci![tspan-animate-part4](figures/tspan-animate-part4.gif)
170