v1.1.2

Text

Installation

Install yarn add @spark-web/text
Source GitHub.com
Bundle unpkg.com

Constrained, purposeful text styles as a component.

Examples

Text large regular
Text standard regular
Text small regular
Text xsmall regular
Text large regular
Text standard regular
Text small regular
Text xsmall regular

Align

Text can be aligned with the align prop.

Left (default)
Center
Right

Overflow strategy

Use the overflowStrategy prop to manage how Text behaves with regard to overflow.

Default
The quick brown fox jumps over the lazy dog.
truncate
The quick brown fox jumps over the lazy dog.
nowrap
The quick brown fox jumps over the lazy dog.
breakword
The quick brown fox jumps over the lazy dog.

Tone

The foreground colour of text can be set by applying a tone. In addition to the foundation tones, “muted” provides a way to de-emphasise text.

neutral
accent
caution
critical
disabled
fieldAccent
info
link
muted
placeholder
positive
primary
primaryActive
primaryHover
secondary
secondaryActive
secondaryHover

Weight

Text is available in two weight: regular and semibold.

Regular
Semibold

Contrast

To ensure text has sufficient contrast, when on a dark background the foreground tones “neutral” and “muted” will be inverted.

neutral
muted

Props

PropTypeDescription

align?

"left" | "center" | "right"

The horizontal alignment.

baseline?

boolean

Apply leading-trim styles.

children?

ReactNode: string | number | false | true | {} | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal

The text content.

data?

DataAttributeMap

Sets data attributes on the component.

id?

string

An identifier which must be unique in the whole document.

inline?

boolean

Display as an inline element.

overflowStrategy?

"nowrap" | "truncate" | "breakword"

Manage how text behaves with regard to overflow.

size?

string | number | symbol

The size of the text.

tabularNumbers?

boolean

When enabled, numbers will be the same width. Similar to a monospaced font.

tone?

"neutral" | "muted" | "link" | "disabled" | "fieldAccent" | "placeholder" | "accent" | "primary" | "primaryHover" | "primaryActive" | "secondary" | "secondaryHover" | "secondaryActive" | "caution" | "critical" | "info" | "positive"

The tone of the text.

transform?

TextTransform: "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "capitalize" | "full-size-kana" | "full-width" | "lowercase" | "none" | "uppercase"

Transform the text casing.

weight?

"regular" | "semibold"

The weight of the text.

Extra props are also passed into the underlying Box component.

© 2023 Brighte Capital Pty Ltd