1e41f4b71Sopenharmony_ci# label
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 **\<label>** component defines labels for the **\<input>**, **\<button>**, and **\<textarea>** components. When a label is clicked, the click effect of the component associated with the label will be triggered.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## Required Permissions
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciNone
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci## Child Components
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ciNot supported
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci## Attributes
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciIn addition to the [universal attributes](js-components-common-attributes.md), the following attributes are supported.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci| Name    | Type    | Default Value | Mandatory  | Description         |
24e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---- | ----------- |
25e41f4b71Sopenharmony_ci| target | string | -    | No   | Attribute ID of the target component.|
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci## Styles
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ciIn addition to the [universal styles](js-components-common-styles.md), the following styles are supported.
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci| Name               | Type                        | Default Value       | Mandatory  | Description                                      |
33e41f4b71Sopenharmony_ci| ----------------- | -------------------------- | ---------- | ---- | ---------------------------------------- |
34e41f4b71Sopenharmony_ci| color             | &lt;color&gt;              | #e5000000  | No   | Font color.                                |
35e41f4b71Sopenharmony_ci| font-size         | &lt;length&gt;             | 30px       | No   | Font size.                                |
36e41f4b71Sopenharmony_ci| allow-scale       | boolean                    | true       | No   | Whether the font size changes with the system's font size settings.<br>For details about how to make the configuration take effect dynamically, see the **config-changes** attribute in the **config.json** file.|
37e41f4b71Sopenharmony_ci| letter-spacing    | &lt;length&gt;             | 0px        | No   | Character spacing (px).                              |
38e41f4b71Sopenharmony_ci| font-style        | string                     | normal     | No   | Font style. Available values are as follows:<br>- **normal**: standard font style.<br>- **italic**: italic font style.|
39e41f4b71Sopenharmony_ci| font-weight       | number \| string | normal     | No   | Font weight. For the number type, the value ranges from 100 to 900. The default value is 400. A larger value indicates a heavier font weight.<br>The value of the number type must be an integer multiple of 100.<br>The value of the string type can be **lighter**, **normal**, **bold**, or **bolder**.|
40e41f4b71Sopenharmony_ci| text-decoration   | string                     | none       | No   | Text decoration. Available values are as follows:<br>- **underline**: An underline is used.<br>- **line-through**: A strikethrough is used.<br>- **none**: The standard text is used.|
41e41f4b71Sopenharmony_ci| text-align        | string                     | start<br>| No   | Text alignment mode. Available values are as follows:<br>- **left**: The text is left-aligned.<br>- **center**: The text is center-aligned.<br>- **right**: The text is right-aligned.<br>- **start**: The text is aligned with the direction in which the text is written.<br>- **end**: The text is aligned with the opposite direction in which the text is written.<br>If the text width is not specified, the alignment effect may not be obvious when the text width is the same as the width of the parent container.|
42e41f4b71Sopenharmony_ci| line-height       | &lt;length&gt;             | 0px        | No   | Text line height. When this parameter is set to **0px**, the text line height is not limited and the font size is adaptive.      |
43e41f4b71Sopenharmony_ci| text-overflow     | string                     | clip       | No   | Takes effect when the maximum number of lines is specified. Available values are as follows:<br>- **clip**: The text is clipped and displayed based on the size of the parent container.<br>- **ellipsis**: The text is displayed based on the size of the parent container. The text that cannot be displayed is replaced with ellipsis. This style must be used together with **max-lines**.|
44e41f4b71Sopenharmony_ci| font-family       | string                     | 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.|
45e41f4b71Sopenharmony_ci| max-lines         | number                     | -          | No   | Maximum number of lines in the text.                              |
46e41f4b71Sopenharmony_ci| min-font-size     | &lt;length&gt;             | -          | No   | Minimum font size in the text. This style must be used together with **max-font-size**. The font size can be changed dynamically. After the maximum and minimum font sizes are set, **font-size** does not take effect.|
47e41f4b71Sopenharmony_ci| max-font-size     | &lt;length&gt;             | -          | No   | Maximum font size in the text. This style must be used together with **min-font-size**. The font size can be changed dynamically. After the maximum and minimum font sizes are set, **font-size** does not take effect.|
48e41f4b71Sopenharmony_ci| font-size-step    | &lt;length&gt;             | 1px        | No   | Step for dynamically adjusting the font size in the text. The minimum and maximum font sizes must be set.           |
49e41f4b71Sopenharmony_ci| prefer-font-sizes | &lt;array&gt;              | -          | No   | Preset preferred font sizes. For dynamic font size adjustment, the preset sizes are used to match the maximum number of lines in the text. If the preferred font sizes were not set, the font size will be adjusted based on the maximum and minimum font sizes and the step you have set. If the maximum number of lines in the text cannot be met, **text-overflow** is used to truncate the text. If this parameter is set, **font-size**, **max-font-size**, **min-font-size**, and **font-size-step** do not take effect.<br>Example: prefer-font-sizes: 12px,14px,16px|
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci## Events
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ciNot supported
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci## Methods
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ciNot supported
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci## Example
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci```html
65e41f4b71Sopenharmony_ci<!--xxx.hml -->
66e41f4b71Sopenharmony_ci<div class="container">
67e41f4b71Sopenharmony_ci  <div class="row">
68e41f4b71Sopenharmony_ci    <label class="label" target="textId">input</label>
69e41f4b71Sopenharmony_ci    <input class="input" id="textId" type="text"></input>
70e41f4b71Sopenharmony_ci  </div>
71e41f4b71Sopenharmony_ci  <div class="row">
72e41f4b71Sopenharmony_ci    <label class="label" target="radioId">radio</label>
73e41f4b71Sopenharmony_ci    <input class="input" id="radioId" type="radio" name="group" value="group"></input>
74e41f4b71Sopenharmony_ci  </div>
75e41f4b71Sopenharmony_ci  <div class="row">
76e41f4b71Sopenharmony_ci    <label class="label" target="checkboxId">checkbox</label>
77e41f4b71Sopenharmony_ci    <input class="input" id="checkboxId" type="checkbox"></input>
78e41f4b71Sopenharmony_ci  </div>
79e41f4b71Sopenharmony_ci</div>
80e41f4b71Sopenharmony_ci```
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci```css
83e41f4b71Sopenharmony_ci/*xxx.css */
84e41f4b71Sopenharmony_ci.container {
85e41f4b71Sopenharmony_ci  flex-direction: column;
86e41f4b71Sopenharmony_ci  margin-left: 20px;
87e41f4b71Sopenharmony_ci}
88e41f4b71Sopenharmony_ci.row {
89e41f4b71Sopenharmony_ci  flex-direction: row;
90e41f4b71Sopenharmony_ci}
91e41f4b71Sopenharmony_ci.label {
92e41f4b71Sopenharmony_ci  width: 200px;
93e41f4b71Sopenharmony_ci  margin-top: 50px;
94e41f4b71Sopenharmony_ci}
95e41f4b71Sopenharmony_ci.input {
96e41f4b71Sopenharmony_ci  margin-left: 100px;
97e41f4b71Sopenharmony_ci  margin-top: 50px;
98e41f4b71Sopenharmony_ci}
99e41f4b71Sopenharmony_ci```
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci![en-us_image_0000001152834002](figures/en-us_image_0000001152834002.png)
102