Skip to content

Text

Text component for displaying text information.

Component Types

Basic Usage

Pass text content through text.

html
<wd-text :text="text"></wd-text>
ts
const text = ref('Reeds fill the sandbar, cold sand with shallow streams. Twenty years since I last visited the South Tower.')

Set Theme

Set theme color through type, supports primary, error, success, warning, default.

html
<wd-text type="primary" text="Primary"></wd-text>
<wd-text type="error" text="Error"></wd-text>
<wd-text type="success" text="Success"></wd-text>
<wd-text type="warning" text="Warning"></wd-text>
<wd-text text="Default"></wd-text>

Mode

Format text through mode, supports text, date, phone, name, price.

html
<wd-text text="18888888888" mode="phone"></wd-text>
<wd-text text="Wang San" mode="name"></wd-text>
<wd-text text="1719976636911" mode="date"></wd-text>

Price

Set mode="price" to display price formatted text.

html
<wd-text text="16354.156" mode="price" type="success" decoration="line-through" prefix="¥" />

Component Styles

Custom Font Color

Set text color through color.

html
<wd-text :text="text" color="#36B8C2"></wd-text>

Bold

Set bold to enable bold text.

html
<wd-text :text="text" bold></wd-text>

Font Size

Set font size through size.

html
<wd-text :text="text" size="16px"></wd-text>

Lines

Set lines to limit the number of displayed lines, showing ellipsis when exceeded.

html
<wd-text :text="text" :lines="2" size="16px"></wd-text>

LineHeight

Set line height through lineHeight.

html
<wd-text :text="text" :lines="2" lineHeight="20px"></wd-text>

Text Decoration

Set text decoration line through decoration.

html
<wd-text :text="text" type="warning" decoration="underline" />

Special Styles

Desensitization

After setting format, desensitization display will be performed when mode is phone or name.

html
<wd-text text="Zhang Changsan" mode="name" :format="true"></wd-text>
<wd-text text="18888888888" mode="phone" :format="true"></wd-text>

Prefix and Suffix Slots

Extend front and back content through prefix, suffix properties or slots with the same name.

html
<wd-text text="12345678901" mode="phone" format type="primary" prefix="Prefix" suffix="Suffix" />

<wd-text text="12345678901" mode="phone" format type="primary">
  <template #prefix>
    <text>Prefix</text>
  </template>
  <template #suffix>Suffix</template>
</wd-text>

Attributes

ParameterDescriptionTypeDefault Value
typeTheme type, optional values are default, primary, success, warning, errorTextTypedefault
textText contentstring | number''
sizeFont sizestring''
modeText processing mode, optional values are text, date, phone, name, priceTextModetext
decorationText decoration, optional values are none, underline, line-through, overlineTextDecorationnone
callWhether to dial when clicking text when mode="phone"booleanfalse
boldWhether boldbooleanfalse
formatWhether to desensitize, only effective when mode is phone and namebooleanfalse
colorText colorstring''
prefixPrefix contentstring-
suffixSuffix contentstring-
linesNumber of display lines, showing ellipsis when exceedednumber-
line-heightText line heightstring''
custom-classRoot node custom class namestring''
custom-styleRoot node custom stylestring''

Events

Event NameDescriptionParameters
clickTriggered when clicking textEvent

Slots

NameDescription
prefixPrefix content
suffixSuffix content

External Style Classes

Class NameDescription
custom-classRoot node style class
custom-styleRoot node inline style

主题定制

CSS 变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置

名称默认值描述
--wot-text-font-size$typography-body-size-main默认文字字号
--wot-text-line-height$typography-body-line--height-size-main默认文字行高
--wot-text-primary-color$primary-6主色文字颜色
--wot-text-success-color$success-main成功文字颜色
--wot-text-error-color$danger-main错误文字颜色
--wot-text-warning-color$warning-main警告文字颜色
--wot-text-default-color$text-auxiliary默认文字颜色

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.