Text

Beta

Text represent a single text line without semantic meaning.

installyarn add @clayui/core
versionNPM Version
useimport {Text} from '@clayui/core';

Introduction

Text is a component that represents a single text line without semantic meaning like a Button. Text can also provide its styles using its props like italic, truncate, monospace, color, weight and size.

Size

The same way as Heading, Text provides its own font size level from 1 to 11 just indicating it in the property size. The default font size is 4.

As API

The HTML tag of this component can be chosen to ensure that the semantics of the text are representative. Text provides a property that allows to display the component depending on the user election. It can be displayed as p or span tag providing a block element or a inline one.

Snippet

Snippet

Font Styles

Italic

Likewise, Text provides a new property that allows you change the font weight of text in italic form.

Truncate

If you want to shortening Text content because it doesn’t fit the layout correctly, you can use truncate property.

Monospace

Text provides a property which sets a font whose letters and characters each occupy the same amount of horizontal space, which is monospace.

Color

Text has the ability to apply different color fonts giving emphasis to the text, you can check here. Notice that is not recommended on light backgrounds due to contrast issues around light text.

Font Weights

As well as Heading, Text provides its own font weight styles from bolder to lighter just indicating it in the property weight. The default font weight is normal.

Text Highlight

The <TextHighlight /> component adds a highlight to the text characters that match the value that can be entered by the user, for example can be used in an Autocomplete component.

API Reference

Text

{ ({ "aria-hidden": ariaHidden, as, children, color, id, italic, monospace, size, truncate, weight, }: Props): JSX.Element; displayName: string; }
Parameters
Properties

aria-hidden

boolean | undefined

State indicates whether the component will be exposed to an accessibility API.

as

"p" | "span" | undefined= "span"

Determine the way in which a text is displayed.

children

React.ReactNode

Text content.

color

ColorType | undefined

Determine the color text.

id

string | undefined

The id global attribute defines an identifier (ID) which must be unique in the whole document.

italic

boolean | undefined

Set the text in italic style.

monospace

boolean | undefined

Set the text in monospace style.

size

TextSize | undefined= 4

Number to set the text size.

truncate

boolean | undefined

Set the text in truncate style.

weight

WeightFont | undefined

Determines the weight of the font.

Returns
Element
Edit this page on GitHub

Contributors

Matuzalém Teles, Sergio Jimenez del Coso

Last edited May 11, 2025 at 5:57:01 PM