Playground

Text

Body text with a size and tone from the scale.

  • Built on native elements
  • A plain p (or the child with asChild); tone is never the only signal, so pair danger text with words.
  • Styles in one file: text.css

Import

import '@monoline/css';
import {Text} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add text

Usage

import {Text} from '@monoline/react';

<div style={{display: 'grid', gap: 'var(--s2)'}}>
  <Text size="lg">Large</Text>
  <Text>Medium</Text>
  <Text size="sm" tone="muted">Small and muted</Text>
  <Text size="xs" tone="danger">Extra small, danger</Text>
</div>

Examples

Sizes and tones

Props

TextProps

PropTypeDefaultDescription
size"sm" | "md" | "lg" | "xs"'md'Type size: `xs`, `sm`, `md` (default) or `lg`.
tone"success" | "warning" | "danger" | "accent" | "default" | "muted" | "ok"'default'Colour role: `default`, `muted`, `success`, `warning`, `danger` or `accent`, the same names as Alert. Never rely on colour alone to carry meaning. `ok` still works.
truncateboolean–One line with an ellipsis.
fullWidthboolean–Lets the text run the full width of its container. By default a paragraph stops at a readable line length (`--measure`). Default false.
asChildboolean–Render the child (a span, label, li) with the text styles.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

This component sets no state attributes.

CSS classes

ClassStylesheet
.texttext.css
.text-accenttext.css
.text-dangertext.css
.text-fulltext.css
.text-lgtext.css
.text-mdtext.css
.text-mutedtext.css
.text-oktext.css
.text-smtext.css
.text-successtext.css
.text-truncatetext.css
.text-warningtext.css
.text-xstext.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.text {
  border-color: var(--accent);
}

Accessibility

  • A plain p (or the child with asChild); tone is never the only signal, so pair danger text with words.