Text
Body-copy primitive with responsive size, weight, alignment, role variants, and truncation.
Renders a <span> via Box by default; switch to p, div, label, strong, or em through the as prop so the document outline stays semantic.
import { Text } from '@arshad-shah/cynosure-react';
export default function Example() {
return <Text>Body copy renders in the Text component.</Text>;
}
Five body sizes are available — xs, sm, md (default), lg, and xl — each pulling family, font-size, and line-height from the matching body composite tokens.
import { Text } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
<Text size="xs">Extra small body copy</Text>
<Text size="sm">Small body copy</Text>
<Text size="md">Medium body copy (default)</Text>
<Text size="lg">Large body copy</Text>
<Text size="xl">Extra large body copy</Text>
</div>
);
}
Weights
Section titled “Weights”Pick from regular, medium, semibold, and bold to shift emphasis without changing scale.
import { Text } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.25rem' }}>
<Text weight="regular">Regular weight</Text>
<Text weight="medium">Medium weight</Text>
<Text weight="semibold">Semibold weight</Text>
<Text weight="bold">Bold weight</Text>
</div>
);
}
Variants
Section titled “Variants”variant layers a role on top of size: caption for de-emphasised metadata, overline for uppercase eyebrow labels, and lead for relaxed lead-in paragraphs. The default body variant leaves typography untouched.
import { Text } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
<Text variant="overline" size="xs">
Section eyebrow
</Text>
<Text variant="lead" size="lg">
Lead paragraph carries the room with a relaxed line-height.
</Text>
<Text>Default body sits in between for sustained reading.</Text>
<Text variant="caption" size="sm">
Caption text holds metadata in muted tone.
</Text>
</div>
);
}
Decorations
Section titled “Decorations”Combine italic, underline, and strikethrough to style inline runs. decorationColor recolours underline and strikethrough independently from the text colour.
import { Text } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.25rem' }}>
<Text italic>Italic emphasis</Text>
<Text underline>Underlined run</Text>
<Text strikethrough>Struck-through value</Text>
<Text underline strikethrough>
Both decorations together
</Text>
</div>
);
}
Truncate
Section titled “Truncate”Pass truncate as a boolean for single-line ellipsis or a number greater than one for multi-line clamp.
import { Text } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.75rem', maxWidth: '20rem' }}>
<Text truncate>
Single-line truncation keeps a label tidy when space is tight and the string runs long.
</Text>
<Text truncate={3}>
Multi-line clamp lets the copy breathe for a few rows before fading out. Useful for card
descriptions where you want a hint of the body without surrendering the layout to an
unbounded paragraph.
</Text>
</div>
);
}
Rendered element
Section titled “Rendered element”Swap the rendered element with as (span, p, div, label, strong, em) so semantics match the surrounding flow without losing styling.
import { Text } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.25rem' }}>
<Text as="p">Rendered as a paragraph block.</Text>
<Text as="span">Inline span run.</Text>
<Text as="strong" weight="semibold">
Strong emphasis
</Text>
<Text as="em" italic>
Emphasised italic
</Text>
</div>
);
}
Accessibility
Section titled “Accessibility”- Choose the rendered element via
asso the document outline stays meaningful — usepfor paragraphs,spanfor inline runs,labelonly inside form contexts. - Avoid Text where a heading belongs; reach for the Heading component when content introduces a section.
- Keep size + weight combinations above the platform contrast minimum;
variant="caption"andvariant="lead"use the muted foreground token and should stay on backgrounds that preserve contrast. truncatehides overflow visually only — supply the full string in the DOM (ortitle) so assistive tech still receives the complete content.
Recipes
Section titled “Recipes”- Pair Text with Heading to build a readable title-and-body grouping.
- Use
variant="overline"withsize="xs"for tight section eyebrows above a Heading. - Drop
asChildonto a framework link to project Text’s typography onto a routed element without an extra wrapper. - For long-form prose, constrain the parent width so line length stays readable.