Skip to content

Text ​

Text component, used to display text information.

Available since version 1.3.4

Basic Usage ​

Set text to set the text content. It is recommended to use the form :text='value'.

html
<wd-text
  text="Reed leaves fill the sandbar, cold sand carries shallow streams. Twenty years later, passing the south tower again. The boat tied under willows is not yet steady, how many days until mid-autumn comes again? Yellow crane at the broken cliff, has my old friend been here? The old rivers and mountains are all filled with new sorrows. Wanting to buy osmanthus flowers and bring wine, but it's never like the wanderings of youth."
></wd-text>

Set Theme ​

Set text theme through the type parameter. We provide five types: 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>

Custom Font Color ​

Set the color property.

html
<wd-text
  text="Reed leaves fill the sandbar, cold sand carries shallow streams. Twenty years later, passing the south tower again. The boat tied under willows is not yet steady, how many days until mid-autumn comes again? Yellow crane at the broken cliff, has my old friend been here? The old rivers and mountains are all filled with new sorrows. Wanting to buy osmanthus flowers and bring wine, but it's never like the wanderings of youth."
  color="#36B8C2"
></wd-text>

Bold Text ​

Set the bold property.

html
<wd-text
  text="Reed leaves fill the sandbar, cold sand carries shallow streams. Twenty years later, passing the south tower again. The boat tied under willows is not yet steady, how many days until mid-autumn comes again? Yellow crane at the broken cliff, has my old friend been here? The old rivers and mountains are all filled with new sorrows. Wanting to buy osmanthus flowers and bring wine, but it's never like the wanderings of youth."
  bold
></wd-text>

Font Size ​

Set the size property.

html
<wd-text
  text="Reed leaves fill the sandbar, cold sand carries shallow streams. Twenty years later, passing the south tower again. The boat tied under willows is not yet steady, how many days until mid-autumn comes again? Yellow crane at the broken cliff, has my old friend been here? The old rivers and mountains are all filled with new sorrows. Wanting to buy osmanthus flowers and bring wine, but it's never like the wanderings of youth."
  size="16px"
></wd-text>

Data Masking ​

Set the format property, effective when mode is phone or name.

html
<wd-text text="Li Si" mode="name" :format="true"></wd-text>
<wd-text text="Zhang Chang San" mode="name" :format="true"></wd-text>
<wd-text text="18888888888" mode="phone" :format="true"></wd-text>

Lines ​

Set the lines property to specify the number of lines of text to display. If set, an ellipsis will be shown when the text exceeds this number of lines. Maximum value is 5.

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

Line Height ​

Set lineHeight for text line height.

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

Prefix and Suffix Slots ​

Set prefix and suffix slots.

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>

Price ​

Set mode="price".

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

Text Decoration ​

Set decoration for text decoration, such as underline, line-through, etc.

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

Events ​

html
<wd-text
  text="Reed leaves fill the sandbar, cold sand carries shallow streams. Twenty years later, passing the south tower again. The boat tied under willows is not yet steady, how many days until mid-autumn comes again? Yellow crane at the broken cliff, has my old friend been here? The old rivers and mountains are all filled with new sorrows. Wanting to buy osmanthus flowers and bring wine, but it's never like the wanderings of youth."
  @click="clickTest"
></wd-text>
typescript
function clickTest() {
  console.log(1)
}

Attributes ​

ParameterDescriptionTypeOptionsDefaultVersion
typeTheme typestring'primary' / 'error' / 'warning' / 'success' / 'default'default1.3.4
textText contentstring / number--1.3.4
sizeFont sizestring--1.3.4
modeText processing modestring'text' / 'date' / 'phone' / 'name' / 'price'text1.3.4+
boldWhether bold, default normalboolean-false1.3.4
formatWhether to mask databooleanEffective when mode is phone or namefalse1.3.4
colorText colorstring--1.3.4
linesNumber of lines to display, if set, ellipsis will show when exceeding. Max value is 5.number--1.3.4
lineHeightText line heightstring--1.3.4
decorationText decoration, underline, line-through, etc.string'underline' / 'line-through' / 'overline'none1.3.4+
prefixPrefix contentstring--1.3.4+
suffixSuffix contentstring--1.3.4+
callWhether to make a call when clicking text in phone modeboolean-false1.3.4

Events ​

Event NameDescriptionParametersVersion
clickTriggered when text is clickedevent1.3.4

Slots ​

Slot NameDescriptionVersion
prefixPrefix slot1.3.4
suffixSuffix slot1.3.4

External Classes ​

Class NameDescriptionVersion
custom-classRoot node style1.3.4
custom-styleRoot node style1.3.4

Source Code ​

Documentation
• Component

Released under the MIT License.

Released under the MIT License.