Skip to content
API 风格:

Text Text ​

LhText typography text: heading levels, semantic colors, decorations, ellipsis and copy.

Basic Usage ​

Heading Levels

Heading 1

Heading 3

Body paragraph

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

<template>
<LhText level="h1">Heading 1</LhText>
<LhText level="h3">Heading 3</LhText>
<LhText>Body paragraph</LhText>
<LhText level="caption">Caption text</LhText>
</template>
vue
<script>
import { LhText } from '@lh-ui/vue3'

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

<template>
<LhText level="h1">Heading 1</LhText>
<LhText level="h3">Heading 3</LhText>
<LhText>Body paragraph</LhText>
<LhText level="caption">Caption text</LhText>
</template>
Decorations & Ellipsis

Bold

Marked highlight

const answer = 42

Truncated after two lines: an enterprise-grade Vue 3 UI library with a Chinese ink-painting visual language, dark mode and full theming.

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

<template>
<div class="demo-row">
  <LhText strong>Bold</LhText>
  <LhText type="danger" mark>Marked highlight</LhText>
  <LhText code>const answer = 42</LhText>
</div>
<LhText :ellipsis="2">Truncated after two lines: an enterprise-grade Vue 3 UI library with a Chinese ink-painting visual language, dark mode and full theming.</LhText>
</template>
vue
<script>
import { LhText } from '@lh-ui/vue3'

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

<template>
<div class="demo-row">
  <LhText strong>Bold</LhText>
  <LhText type="danger" mark>Marked highlight</LhText>
  <LhText code>const answer = 42</LhText>
</div>
<LhText :ellipsis="2">Truncated after two lines: an enterprise-grade Vue 3 UI library with a Chinese ink-painting visual language, dark mode and full theming.</LhText>
</template>
Copyable

Copy this text with the button

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

<template>
<LhText copyable>Copy this text with the button</LhText>
</template>
vue
<script>
import { LhText } from '@lh-ui/vue3'

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

<template>
<LhText copyable>Copy this text with the button</LhText>
</template>

Text API ​

Props ​

NameDescriptionTypeDefault
levelHeading level / paragraph form: h1–h6, p, caption"h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "caption"—
typeSemantic color: default, secondary, success / warning / danger"default" | "secondary" | "success" | "warning" | "danger"—
strongBoldbooleanfalse
italicItalicbooleanfalse
underlineUnderlinebooleanfalse
markMarked highlightbooleanfalse
codeCode stylebooleanfalse
ellipsisEllipsis: true for single line, number for line clamp (max 10)number | booleanfalse
copyableAppends a copy button that writes to clipboardbooleanfalse
copyLabelAccessibility name of the copy buttonstring—
disabledDisabled: grayed text, no copy buttonbooleanfalse
tagCustom render tag (defaults by level)string—
sxQuick layout props applied as inline stylesLhSxProps—

Events ​

NameDescriptionType
copyFired when the copy button is clicked(text: string)

Slots ​

NameDescription
defaultText content

Accessibility ​

  • The copy button is linked to the text via aria-labelledby
  • h1–h6 render as semantic heading tags, caption as inline span

Type Definitions ​

The TypeScript type structures exported by this component (auto-extracted from packages/components/text/src/types.ts and @lh-ui/share/core/* sources; click each entry to expand; see the Props table above for attribute descriptions):

LhTextProps
ts
export interface LhTextProps {
  level?: LhTextLevel
  type?: LhTextType
  strong?: boolean
  italic?: boolean
  underline?: boolean
  mark?: boolean
  code?: boolean
  ellipsis?: boolean | number
  copyable?: boolean
  copyLabel?: string
  disabled?: boolean
  tag?: string
  sx?: LhSxProps
}

Beauty of tradition, foundation of code