Skip to content
API 风格:

Text 文字 ​

LhText 排版文字:標題層級、語義色、修飾、省略與一鍵複製。

基礎用法 ​

標題層級

一級標題

三級標題

正文段落

輔助說明小字
vue
<script setup lang="ts">
import { LhText } from '@lh-ui/vue3'
</script>

<template>
<LhText level="h1">一級標題</LhText>
<LhText level="h3">三級標題</LhText>
<LhText>正文段落</LhText>
<LhText level="caption">輔助說明小字</LhText>
</template>
vue
<script>
import { LhText } from '@lh-ui/vue3'

export default {
  components: { LhText },
}
</script>

<template>
<LhText level="h1">一級標題</LhText>
<LhText level="h3">三級標題</LhText>
<LhText>正文段落</LhText>
<LhText level="caption">輔助說明小字</LhText>
</template>
修飾與省略

加粗

標記重點

const answer = 42

超過兩行時截斷:組件庫以「國風水墨」為視覺語言,提供常用業務組件的完整實現。

vue
<script setup lang="ts">
import { LhText } from '@lh-ui/vue3'
</script>

<template>
<div class="demo-row">
  <LhText strong>加粗</LhText>
  <LhText type="danger" mark>標記重點</LhText>
  <LhText code>const answer = 42</LhText>
</div>
<LhText :ellipsis="2">超過兩行時截斷:組件庫以「國風水墨」為視覺語言,提供常用業務組件的完整實現。</LhText>
</template>
vue
<script>
import { LhText } from '@lh-ui/vue3'

export default {
  components: { LhText },
}
</script>

<template>
<div class="demo-row">
  <LhText strong>加粗</LhText>
  <LhText type="danger" mark>標記重點</LhText>
  <LhText code>const answer = 42</LhText>
</div>
<LhText :ellipsis="2">超過兩行時截斷:組件庫以「國風水墨」為視覺語言,提供常用業務組件的完整實現。</LhText>
</template>
可複製

點擊按鈕複製這段文字

vue
<script setup lang="ts">
import { LhText } from '@lh-ui/vue3'
</script>

<template>
<LhText copyable>點擊按鈕複製這段文字</LhText>
</template>
vue
<script>
import { LhText } from '@lh-ui/vue3'

export default {
  components: { LhText },
}
</script>

<template>
<LhText copyable>點擊按鈕複製這段文字</LhText>
</template>

Text API ​

屬性 ​

屬性名說明類型預設值
level標題層級與段落形態:h1~h6、p、captionLhTextLevel'p'
type語義色:default 常規、secondary 次要、success / warning / danger 狀態色LhTextType'default'
strong加粗booleanfalse
italic斜體booleanfalse
underline下劃線booleanfalse
mark標記高亮booleanfalse
code程式碼風格booleanfalse
ellipsis省略:true 單行省略,數字按行數截斷(上限 10)boolean | numberfalse
copyable附加複製按鈕booleanfalse
copyLabel複製按鈕的無障礙名稱string—
disabled停用:文字灰化且不渲染複製按鈕booleanfalse
tag自訂渲染標籤string—
sx快速版面配置屬性LhSxProps—

事件 ​

屬性名說明類型
copy點擊複製按鈕時觸發(text: string)

插槽 ​

屬性名說明
default文字內容

無障礙 ​

  • 複製按鈕經 aria-labelledby 與文字關聯
  • h1~h6 渲染為語義化標題標籤