1e41f4b71Sopenharmony_ci# button
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci>  **NOTE**
4e41f4b71Sopenharmony_ci>
5e41f4b71Sopenharmony_ci>  This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciThe **\<button>** component includes capsule, circle, text, arc, and download buttons.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Child Components
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ciNot supported
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## Attributes
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciIn addition to the [universal attributes](js-components-common-attributes.md), the following attributes are supported.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci| Name                    | Type     | Default Value  | Mandatory  | Description                                      |
20e41f4b71Sopenharmony_ci| ---------------------- | ------- | ----- | ---- | ---------------------------------------- |
21e41f4b71Sopenharmony_ci| type                   | string  | -     | No   | Button type. The value cannot be dynamically updated. By default, a capsule-like button is displayed. Unlike the capsule button, the capsule-like button allows its corners to be configured using **border-radius**. The options are as follows:<br>- **capsule**: capsule button with fillets, background color, and text.<br>- **circle**: circle button that can accommodate icons.<br>- **text**: text button, which displays only text.<br>- **arc**: arc button. This value is applicable to wearables only.<br>- **download**: download button, with an extra download progress bar.|
22e41f4b71Sopenharmony_ci| value                  | string  | -     | No   | Text value of the button.                             |
23e41f4b71Sopenharmony_ci| icon                   | string  | -     | No   | Path of the button icon. The supported icon formats are JPG, PNG, and SVG.           |
24e41f4b71Sopenharmony_ci| placement<sup>5+</sup> | string  | end   | No   | Position of the button icon in text. This attribute is valid only when **type** is not set. Available values are as follows:<br>- **start**: The button icon is at the beginning of the text.<br>- **end**: The button icon is at the end of the text.<br>- **top**: The button icon is at the top of the text.<br>- **bottom**: The button icon is at the bottom of the text.|
25e41f4b71Sopenharmony_ci| waiting                | boolean | false | No   | Waiting status. When this attribute is set to **true**, a loading animation is displayed on the left of the text. This attribute does not work for download buttons.|
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci## Styles
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci### When the Button Type Is Not arc
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ciIn addition to the [universal styles](js-components-common-styles.md), the following styles are supported.
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci| Name         | Type                        | Default Value            | Mandatory  | Description                                      |
36e41f4b71Sopenharmony_ci| ----------- | -------------------------- | --------------- | ---- | ---------------------------------------- |
37e41f4b71Sopenharmony_ci| text-color  | &lt;color&gt;              | \#007dff | No   | Text color of the button.                                |
38e41f4b71Sopenharmony_ci| font-size   | &lt;length&gt;             | 16px      | No   | Font size of the button.                                |
39e41f4b71Sopenharmony_ci| allow-scale | boolean                    | true            | No   | Whether the font size changes with the system's font size settings.<br>If the **config-changes** tag of **fontSize** is configured for abilities in the **config.json** file, the setting takes effect without application restart.|
40e41f4b71Sopenharmony_ci| font-style  | string                     | normal          | No   | Font style of the button.                                |
41e41f4b71Sopenharmony_ci| font-weight | number \| string | normal          | No   | Font weight of the button. For details, see **font-weight** of the [**\<text>** component](js-components-basic-text.md#styles).|
42e41f4b71Sopenharmony_ci| font-family | &lt;string&gt;             | sans-serif      | No   | Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the specified [custom font](js-components-common-customizing-font.md) is used for the text.|
43e41f4b71Sopenharmony_ci| icon-width  | &lt;length&gt;             | -               | No   | Width of the internal icon of a circle button. The entire circle button is filled by default.<br>This style must be set when the icon uses the SVG image.|
44e41f4b71Sopenharmony_ci| icon-height | &lt;length&gt;             | -               | No   | Height of the internal icon of a circle button. The entire circle button is filled by default.<br>This style must be set when the icon uses the SVG image.|
45e41f4b71Sopenharmony_ci| radius      | &lt;length&gt;             | -               | No   | Corner radius of the button. For a circle button, this style takes precedence over **width** and **height** in the universal styles.|
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci### When the Button Type Is arc
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ciIn addition to the **background-color**, **opacity**, **display**, **visibility**, **position**, and **[left|top|right|bottom]** styles in [Universal Styles](js-components-common-styles.md), the following styles are supported.
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci| Name         | Type                        | Default Value       | Mandatory  | Description                                      |
53e41f4b71Sopenharmony_ci| ----------- | -------------------------- | ---------- | ---- | ---------------------------------------- |
54e41f4b71Sopenharmony_ci| text-color  | &lt;color&gt;              | \#de0000   | No   | Text color of the arc button.                              |
55e41f4b71Sopenharmony_ci| font-size   | &lt;length&gt;             | 37.5px     | No   | Font size of the arc button.                              |
56e41f4b71Sopenharmony_ci| allow-scale | boolean                    | true       | No   | Whether the font size changes with the system's font size settings.          |
57e41f4b71Sopenharmony_ci| font-style  | string                     | normal     | No   | Font style of the arc button.                              |
58e41f4b71Sopenharmony_ci| font-weight | number \| string | normal     | No   | Font weight of the arc button. For details, see **font-weight** of the [**\<text>**](js-components-basic-text.md#styles) component. |
59e41f4b71Sopenharmony_ci| font-family | &lt;string&gt;             | sans-serif | No   | Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the specified [custom font](js-components-common-customizing-font.md) is used for the text.|
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci## Events
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ciThe [universal events](js-components-common-events.md) are supported.
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci## Methods
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ciThe [universal methods](js-components-common-methods.md) are supported.
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ciWhen the button type is **download**, the following methods are supported.
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci| Name         | Parameters                            | Description                                      |
74e41f4b71Sopenharmony_ci| ----------- | ------------------------------ | ---------------------------------------- |
75e41f4b71Sopenharmony_ci| setProgress | { progress:percent } | Progress bar of the download button. The value ranges from 0 to 100. The progress bar is displayed if the value is greater than 0. If the value is greater than or equal to 100, the progress bar is not displayed.<br>The text displayed on the progress bar is subject to the **value** settings.|
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci## Example
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci```html
80e41f4b71Sopenharmony_ci<!-- xxx.hml -->
81e41f4b71Sopenharmony_ci<div class="div-button">
82e41f4b71Sopenharmony_ci  <button class="first" type="capsule" value="Capsule button"></button>
83e41f4b71Sopenharmony_ci  <button class="button circle" type="circle" icon="common/ic_add_default.png"></button>
84e41f4b71Sopenharmony_ci  <button class="button text" type="text">Text button</button>
85e41f4b71Sopenharmony_ci  <button class="button download" type="download" id="download-btn"
86e41f4b71Sopenharmony_ci    onclick="progress">{{downloadText}}</button>
87e41f4b71Sopenharmony_ci  <button class="last" type="capsule" waiting="true">Loading</button>
88e41f4b71Sopenharmony_ci</div>
89e41f4b71Sopenharmony_ci```
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci```css
92e41f4b71Sopenharmony_ci/* xxx.css */ 
93e41f4b71Sopenharmony_ci.div-button {
94e41f4b71Sopenharmony_ci  flex-direction: column;
95e41f4b71Sopenharmony_ci  align-items: center;
96e41f4b71Sopenharmony_ci}
97e41f4b71Sopenharmony_ci.first{
98e41f4b71Sopenharmony_ci  background-color: #F2F2F2;
99e41f4b71Sopenharmony_ci  text-color: #0D81F2;
100e41f4b71Sopenharmony_ci}
101e41f4b71Sopenharmony_ci.button {
102e41f4b71Sopenharmony_ci  margin-top: 15px;
103e41f4b71Sopenharmony_ci}
104e41f4b71Sopenharmony_ci.last{
105e41f4b71Sopenharmony_ci  background-color: #F2F2F2;
106e41f4b71Sopenharmony_ci  text-color: #969696;
107e41f4b71Sopenharmony_ci  margin-top: 15px;
108e41f4b71Sopenharmony_ci  width: 280px;
109e41f4b71Sopenharmony_ci  height:72px;
110e41f4b71Sopenharmony_ci}
111e41f4b71Sopenharmony_ci.button:waiting {
112e41f4b71Sopenharmony_ci  width: 280px;
113e41f4b71Sopenharmony_ci}
114e41f4b71Sopenharmony_ci.circle {
115e41f4b71Sopenharmony_ci  background-color: #007dff;
116e41f4b71Sopenharmony_ci  radius: 72px;
117e41f4b71Sopenharmony_ci  icon-width: 72px;
118e41f4b71Sopenharmony_ci  icon-height: 72px;
119e41f4b71Sopenharmony_ci}
120e41f4b71Sopenharmony_ci.text {
121e41f4b71Sopenharmony_ci  text-color: red;
122e41f4b71Sopenharmony_ci  font-size: 40px;
123e41f4b71Sopenharmony_ci  font-weight: 900;
124e41f4b71Sopenharmony_ci  font-family: sans-serif;
125e41f4b71Sopenharmony_ci  font-style: normal;
126e41f4b71Sopenharmony_ci}
127e41f4b71Sopenharmony_ci.download {
128e41f4b71Sopenharmony_ci  width: 280px;
129e41f4b71Sopenharmony_ci  text-color: white;
130e41f4b71Sopenharmony_ci  background-color: #007dff;
131e41f4b71Sopenharmony_ci}
132e41f4b71Sopenharmony_ci```
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci```js
135e41f4b71Sopenharmony_ci// xxx.js
136e41f4b71Sopenharmony_ciexport default {
137e41f4b71Sopenharmony_ci  data: {
138e41f4b71Sopenharmony_ci    count: 5,
139e41f4b71Sopenharmony_ci    downloadText: "Download"
140e41f4b71Sopenharmony_ci  },
141e41f4b71Sopenharmony_ci  progress(e) {
142e41f4b71Sopenharmony_ci    this.count+= 10;
143e41f4b71Sopenharmony_ci    this.downloadText = this.count+ "%";
144e41f4b71Sopenharmony_ci    this.$element('download-btn').setProgress({ progress: this.count});
145e41f4b71Sopenharmony_ci    if (this.count>= 100) {
146e41f4b71Sopenharmony_ci      this.downloadText = "Done";
147e41f4b71Sopenharmony_ci    }
148e41f4b71Sopenharmony_ci  }
149e41f4b71Sopenharmony_ci}
150e41f4b71Sopenharmony_ci```
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci![1](figures/1.png)
153