• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# line
2
3
4>  **NOTE**
5>
6>  This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
7
8The **\<line>** component is used to draw a line.
9
10## Required Permissions
11
12None
13
14
15## Child Components
16
17The following are supported: [\<animate>](js-components-svg-animate.md), [\<animateMotion>](js-components-svg-animatemotion.md), and [\<animateTransform>](js-components-svg-animatetransform.md).
18
19
20## Attributes
21
22The [universal attributes](../arkui-js/js-components-svg-common-attributes.md) and the attributes listed below are supported.
23
24| Name| Type| Default Value| Mandatory| Description|
25| -------- | -------- | -------- | -------- | -------- |
26| id | string | - | No| Unique ID of the component.|
27| x1 | &lt;length&gt;\|&lt;percentage&gt; | - | No| X-coordinate of the start point of the line. Attribute animations are supported.|
28| y1 | &lt;length&gt;\|&lt;percentage&gt; | - | No| Y-coordinate of the start point of the line. Attribute animations are supported.|
29| x2 | &lt;length&gt;\|&lt;percentage&gt; | - | No| X-coordinate of the end point of the line. Attribute animations are supported.|
30| y2 | &lt;length&gt;\|&lt;percentage&gt; | - | No| Y-coordinate of the end point of the line. Attribute animations are supported.|
31
32
33## Example
34
35```html
36<!-- xxx.hml -->
37<div class="container">
38  <svg width="400" height="400">
39    <line x1="10" x2="300" y1="50" y2="50" stroke-width="4" fill="white" stroke="blue"></line>
40    <line x1="10" x2="300" y1="100" y2="100" stroke-width="4" fill="white" stroke="blue"></line>
41    <line x1="10" x2="300" y1="150" y2="150" stroke-width="10" stroke="red" stroke-dasharray="5 3" stroke-dashoffset="3"></line>
42    // round: At the end of each path the stroke is extended by a half circle with a diameter equal to the stroke width.
43    <line x1="10" x2="300" y1="200" y2="200" stroke-width="10" stroke="black" stroke-linecap="round"></line>
44    // butt: The stroke for each path does not extend beyond its two endpoints.
45    <line x1="10" x2="300" y1="220" y2="220" stroke-width="10" stroke="black" stroke-linecap="butt"></line>
46    // square: At the end of each path the stroke is extended by a half circle, with the width being equal to half of the stroke width, and the height being equal to the stroke width.
47    <line x1="10" x2="300" y1="240" y2="240" stroke-width="10" stroke="black" stroke-linecap="square"></line>
48  </svg>
49</div>
50```
51
52
53![en-us_image_0000001127284954](figures/en-us_image_0000001127284954.png)
54