> For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt.

# text

文本渲染组件，是展示文字内容的基础元件，支持文字样式配置。

<iframe src="https://developer.doubao.com/docs-preview/component-simulator/?caseId=text"
  title="组件示例 text"
  width="100%"
  height="700"
  loading="lazy"
  style="width:100%;height:700px;border:0;border-radius:16px;overflow:hidden;"
></iframe>

## 扫码预览

![扫码预览 text](https://api.qrserver.com/v1/create-qr-code/?size=200x200\&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fcomponent%252Ftext%252Findex)

## Props

<table>
<thead>
<tr><th width="140">属性名</th><th width="240">类型</th><th width="120">默认值</th><th width="80">必填</th><th width="360">说明</th></tr>
</thead>
<tbody>
<tr><td>children</td><td><code>ReactNode</code></td><td>-</td><td>否</td><td>子元素</td></tr>
<tr><td>className</td><td><code>string</code></td><td>-</td><td>否</td><td>组件类名</td></tr>
<tr><td>customContextMenu</td><td><code>boolean</code></td><td>false</td><td>否</td><td>开启文本选择后，是否使用自定义弹窗菜单</td></tr>
<tr><td>flatten</td><td><code>boolean</code></td><td>true</td><td>否</td><td>是否将节点扁平化以加速渲染，开启文本选择等需要真实节点的能力时需设为 false</td></tr>
<tr><td>id</td><td><code>string</code></td><td>-</td><td>否</td><td>元素的唯一标识</td></tr>
<tr><td>key</td><td><code>string | number | null</code></td><td>-</td><td>否</td><td>React key 属性</td></tr>
<tr><td>onClick</td><td><code>(event: TouchEvent) =&gt; void</code></td><td>-</td><td>否</td><td>点击时的回调函数</td></tr>
<tr><td>onLayout</td><td><code>(event: LayoutEvent) =&gt; void</code></td><td>-</td><td>否</td><td>文本布局完成时触发，事件对象包含文本布局信息</td></tr>
<tr><td>onSelectionChange</td><td><code>(event: SelectionChangeEvent) =&gt; void</code></td><td>-</td><td>否</td><td>文本选择变化时触发（需开启 text-selection）</td></tr>
<tr><td>ref</td><td><code>Ref&lt;NodesRef&gt;</code></td><td>-</td><td>否</td><td>用于获取组件实例的 ref</td></tr>
<tr><td>style</td><td><code>CSSProperties</code></td><td>-</td><td>否</td><td>组件样式</td></tr>
<tr><td>tailColorConvert</td><td><code>boolean</code></td><td>false</td><td>否</td><td>文本截断时，省略号颜色是否使用外层 text 标签样式（默认使用最近 inline-text 样式）</td></tr>
<tr><td>textMaxline</td><td><code>string</code></td><td>-</td><td>否</td><td>文本显示的最大行数，超出将显示省略号</td></tr>
<tr><td>textSelection</td><td><code>boolean</code></td><td>false</td><td>否</td><td>是否开启文本选择功能，开启时需同时设置 <code>flatten={false}</code></td></tr>
<tr><td>textSingleLineVerticalAlign</td><td><code>&quot;bottom&quot; | &quot;top&quot; | &quot;center&quot; | &quot;normal&quot;</code></td><td>'normal'</td><td>否</td><td>单行纯文本在行内垂直居中/对齐方式，inline 文本不支持</td></tr>
</tbody>
</table>
