# textPath The **\** component is used to draw text along the path. > **NOTE** > - This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > > - This component can have **\** components nested for segmenting. > > - This component can only be nested in the **\** component. ## Required Permissions None ## Child Components The **[\](js-components-svg-tspan.md)** child component is supported. ## Attributes The attributes in the following table are supported. | Name | Type | Default Value| Description | | -------------- | ---------------------------------- | ------ | ------------------------------------------------------------ | | id | string | - | Unique ID of the component. | | path | string | 0 | Shape of the path.
The meanings of the letters are as follows:
- M = moveto
- L = lineto
- H = horizontal lineto
- V = vertical lineto
- C = curveto
- S = smooth curveto
- Q = quadratic Belzier curve
- T = smooth quadratic Belzier curveto
- A = elliptical Arc
- Z = closepath
Default value: **0**| | startOffset | <length>\|<percentage> | 0 | Offset of the text start point relative to the path start point.
Default value: **0** | | font-size | <length> | 30px | Font size.
Default value: **30px** | | fill | <color> | black | Font fill color.
Default value: **black** | | by | number | - | Attribute offset relative to the specified animation. By default, **from** is the original attribute value. | | opacity | number | 1 | 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.
Default value: **0**| | fill-opacity | number | 1.0 | Font fill opacity.
Default value: **1.0** | | stroke | <color> | black | Stroke color.
Default value: **black** | | stroke-width | number | 1px | Stroke width.
Default value: **1px** | | stroke-opacity | number | 1.0 | Stroke opacity.
Default value: **1.0** | ## Example The following is an example of the **\** attributes, where text is drawn along the path specified by **path**, and the start point is offset by 20% of the **path** length. (The drawn **\** curve is for reference only.) ```html
This is textpath test.
``` ```css /* xxx.css */ .container { flex-direction: row; justify-content: flex-start; align-items: flex-start; height: 1200px; width: 600px; } ``` ![textpath-part1](figures/textpath-part1.png) Combination of **\** and **\** ```html
This is tspan onTextPath. Let's play. 12345678912354567891234567891234567891234567891234567890
``` ![textpath-part2](figures/textpath-part2.png) ```html
This is TextPath. This is tspan onTextPath. Let's play. 12345678912354567891234567891234567891234567891234567890
``` ![textpath-part3](figures/textpath-part3.png) ```html
This is TextPath. This is first tspan. This is second tspan. 12345678912354567891234567891234567891234567891234567890
``` ![textpath-part4](figures/textpath-part4.png) The following is an example of the **startOffset** animation, where the value of **startOffset** changes from 10% to 40%, and the text is not drawn when its length exceeds the path length range. ```css /* xxx.css */ .container { flex-direction: row; justify-content: flex-start; align-items: flex-start; height: 3000px; width: 1080px; } ``` ```html
This is tspan onTextPath. Let's play. 12345678912354567891234567891234567891234567891234567890
``` ![textpath-animate1](figures/textpath-animate1.gif) Attribute animation of the **\** and **\** in combination ```html
This is TextPath. tspan attribute x|rotate tspan static. tspan attribute dx|opacity tspan move
``` ![textpath-animate2](figures/textpath-animate2.gif) (1) **"tspan attribute x|rotate"**: The beginning of the text is offset from 50 px to 100 px, and the text rotates clockwise by 0 degrees to 360 degrees. (2) **"tspan attribute dx|opacity"**: The text is drawn after the "tspan static." drawing is complete. The horizontal offset moves from 0% to 30%, and the opacity changes from shallow to deep. (3) **tspan move**: After the previous **\** is drawn, the next **\** is drawn with an offset of 5%, creating the effect of following the previous **\**. Attribute animation of the **\** and **\** in combination ```html
This is TextPath. tspan attribute fill|fill-opacity tspan attribute font-size Single tspan
``` ![textpath-animate3](figures/textpath-animate3.gif) (1) **"This is TextPath."**: The first segment of text, in the size of 30px and color of \#D2691E is drawn on the path without offset. (2) **"tspan attribute fill|fill-opacity"**: The new segment of text is 20px offset from the end of the previous text segment. The text color changes from blue to red, and the opacity changes from light to deep. (3) **"tspan attribute font-size"**: The new segment of text is 20px offset from the end of the previous text segment. While the start point of the text is static, the font size shifts from 10px to 50px and the overall length is continuously prolonged. (4) **"Single tspan"**: A horizontal line is drawn at the end of the previous segment, creating the effect of following the previous segment. Attribute animation of the **\** and **\** in combination ```html
This is TextPath. tspan attribute stroke tspan attribute stroke-width-opacity
``` ![textpath-animate4](figures/textpath-animate4.gif) (1) **"tspan attribute stroke"**: The stroke color gradually changes from red to green. (2) **"tspan attribute stroke-width-opacity"**: The stroke width changes from 1px to 5px, and the opacity changes from shallow to deep.