Text Text
LhText typography text: heading levels, semantic colors, decorations, ellipsis and copy.
Basic Usage
Heading Levels
Heading 1
Heading 3
Body paragraph
Caption textvue
<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
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
| Name | Description | Type | Default |
|---|---|---|---|
| level | Heading level / paragraph form: h1–h6, p, caption | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "caption" | — |
| type | Semantic color: default, secondary, success / warning / danger | "default" | "secondary" | "success" | "warning" | "danger" | — |
| strong | Bold | boolean | false |
| italic | Italic | boolean | false |
| underline | Underline | boolean | false |
| mark | Marked highlight | boolean | false |
| code | Code style | boolean | false |
| ellipsis | Ellipsis: true for single line, number for line clamp (max 10) | number | boolean | false |
| copyable | Appends a copy button that writes to clipboard | boolean | false |
| copyLabel | Accessibility name of the copy button | string | — |
| disabled | Disabled: grayed text, no copy button | boolean | false |
| tag | Custom render tag (defaults by level) | string | — |
| sx | Quick layout props applied as inline styles | LhSxProps | — |
Events
| Name | Description | Type |
|---|---|---|
| copy | Fired when the copy button is clicked | (text: string) |
Slots
| Name | Description |
|---|---|
| default | Text content |
Accessibility
- The copy button is linked to the text via
aria-labelledby h1–h6render as semantic heading tags,captionas inlinespan
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
}
