• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# span
2<!--Kit: ArkUI-->
3<!--Subsystem: ArkUI-->
4<!--Owner: @xiangyuan6-->
5<!--Designer: @pssea-->
6<!--Tester: @jiaoaozihao-->
7<!--Adviser: @HelloCrease-->
8
9>  **说明:**
10>  从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
11
12作为&lt;[text](js-components-basic-text.md)&gt;子组件提供文本修饰能力。
13
14## 权限列表
15
1617
18
19## 子组件
20
2122
23
24## 属性
25
26支持[通用属性](js-components-common-attributes.md)。
27
28>  **说明:**
29>  不支持focusable和disabled属性。
30
31
32## 样式
33
34仅支持如下样式:
35
36| 名称              | 类型                         | 默认值        | 必填   | 描述                                       |
37| --------------- | -------------------------- | ---------- | ---- | ---------------------------------------- |
38| color           | &lt;color&gt;              | -          | 否    | 设置文本段落的文本颜色。                             |
39| font-size       | &lt;length&gt;             | 30px       | 否    | 设置文本段落的文本尺寸。                             |
40| allow-scale     | boolean                    | true       | 否    | 设置文本段落的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。true表示跟随系统放大缩小,false表示不跟随系统放大缩小。<br/>如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 |
41| font-style      | string                     | normal     | 否    | 设置文本段落的字体样式,见[text组件font-style的样式属性](js-components-basic-text.md#样式)。 |
42| font-weight     | number&nbsp;\|&nbsp;string | normal     | 否    | 设置文本段落的字体粗细,见[text组件font-weight的样式属性](js-components-basic-text.md#样式)。 |
43| text-decoration | string                     | none       | 否    | 设置文本段落的文本修饰,见[text组件text-decoration样式属性](js-components-basic-text.md#样式)。 |
44| font-family     | string                     | sans-serif | 否    | 设置文本段落的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 |
45
46
47## 事件
48
49仅支持[通用事件](js-components-common-events.md)中的click事件。
50
51
52## 方法
53
54不支持。
55
56
57## 示例
58
59```html
60<!-- xxx.hml -->
61<div class="container">
62  <text class="title">
63    <span class="spanTxt">span</span>
64  </text>
65</div>
66```
67
68```css
69/* xxx.css */
70.container {
71  display: flex;
72  justify-content: center;
73  align-items: center;
74}
75.title {
76  font-size: 30px;
77  text-align: center;
78  width: 100%;
79  height: 100px;
80}
81.spanTxt{
82  color: chartreuse;
83  font-size: 80px;
84}
85```
86
87![zh-cn_image_0000001152588626](figures/zh-cn_image_0000001152588626.png)
88