Text
Body text with a size and tone from the scale.
SourceStyles source@monoline/react 0.4.0Markdown for AI toolsstable
- 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
| Prop | Type | Default | Description |
|---|---|---|---|
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. |
truncate | boolean | – | One line with an ellipsis. |
fullWidth | boolean | – | Lets the text run the full width of its container. By default a paragraph stops at a readable line length (`--measure`). Default false. |
asChild | boolean | – | 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
| Class | Stylesheet |
|---|---|
.text | text.css |
.text-accent | text.css |
.text-danger | text.css |
.text-full | text.css |
.text-lg | text.css |
.text-md | text.css |
.text-muted | text.css |
.text-ok | text.css |
.text-sm | text.css |
.text-success | text.css |
.text-truncate | text.css |
.text-warning | text.css |
.text-xs | text.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.