Examples
Basic hierarchy
Compose a heading, supporting line, and paragraph without losing their semantic roles.
Make hierarchy visible
A supporting line gives the section a clear starting point.Paragraph keeps longer explanations readable with the same type scale and semantic color roles.
Heading, supporting text, and paragraph
import { Heading, Paragraph, Text } from "@phuctech/ui/components/typography";
export function Example() {
return (
<div className="grid gap-3">
<Heading level={2}>Make hierarchy visible</Heading>
<Text tone="muted">A supporting line gives the section a clear starting point.</Text>
<Paragraph>
Paragraph keeps longer explanations readable with the same type scale and semantic color roles.
</Paragraph>
</div>
);
}
Heading levels
Use the level prop for document structure and let the visual size follow the hierarchy by default.
Workspace overview
Recent activity
Invite a teammate
Delivery preferences
Heading levels from h1 through h4
import { Heading } from "@phuctech/ui/components/typography";
export function Example() {
return (
<div className="grid gap-3">
<Heading level={1}>Workspace overview</Heading>
<Heading level={2}>Recent activity</Heading>
<Heading level={3}>Invite a teammate</Heading>
<Heading level={4}>Delivery preferences</Heading>
</div>
);
}
Independent sizes
A heading level and its visual size are independent so a nested section can stay proportionate.
Compact heading
Default heading
Section heading
Feature heading
Display heading
Heading size comparison with one display treatment
import { Heading } from "@phuctech/ui/components/typography";
export function Example() {
return (
<div className="grid gap-3">
<Heading level={2} size="sm">Compact heading</Heading>
<Heading level={2} size="md">Default heading</Heading>
<Heading level={2} size="lg">Section heading</Heading>
<Heading level={2} size="xl">Feature heading</Heading>
<Heading level={2} size="display" font="display">Display heading</Heading>
</div>
);
}
Semantic tones
Use readable words and semantic tones together; color never carries meaning alone.
Text tones with readable status messages
import { Text } from "@phuctech/ui/components/typography";
export function Example() {
return (
<div className="grid gap-2">
<Text>Primary text carries the main message.</Text>
<Text tone="muted">Muted text supports the message without competing with it.</Text>
<Text tone="brand" weight="semibold">Brand text points to an important destination.</Text>
<Text tone="success">Saved successfully.</Text>
<Text tone="warning">Review is needed before continuing.</Text>
<Text tone="danger">This action could not be completed.</Text>
<Text tone="info">The next sync starts in a few minutes.</Text>
</div>
);
}
Meaningful formatting
Use native inline elements for emphasis, changed values, highlights, and code.
Use strong for importance, emphasis for a change in voice, underline for a named reference, deleted copy for an obsolete value, mark for a relevant match, and inline code for a token.
Semantic inline formatting inside Paragraph
import { Paragraph } from "@phuctech/ui/components/typography";
export function Example() {
return (
<Paragraph>
Use <strong>strong</strong> for importance, <em>emphasis</em> for a change in voice, <u>underline</u> for a named reference, <s>deleted copy</s> for an obsolete value, <mark>mark</mark> for a relevant match, and <code>inline code</code> for a token.
</Paragraph>
);
}
Readable paragraphs
Paragraph keeps body copy at the shared reading rhythm and measure.
A comfortable reading measure keeps instructions easy to scan. Keep one idea per paragraph, use sentence case, and break up dense explanations with meaningful headings or lists.
Paragraph constrained to the readable measure
import { Paragraph } from "@phuctech/ui/components/typography";
export function Example() {
return (
<Paragraph className="max-w-[var(--layout-readable-max)]">
A comfortable reading measure keeps instructions easy to scan. Keep one idea per paragraph, use sentence case, and break up dense explanations with meaningful headings or lists.
</Paragraph>
);
}
Single-line ellipsis
Opt into one-line truncation for constrained rows and provide a visible way to read the full value.
View full name
North star migration workspace with a deliberately long name
Single-line truncation with a visible full-value disclosure
import { Paragraph, Text } from "@phuctech/ui/components/typography";
const projectName = "North star migration workspace with a deliberately long name";
export function Example() {
return (
<div className="grid max-w-sm gap-3">
<Text truncate className="block rounded-md border border-border bg-card px-3 py-2" title={projectName}>
{projectName}
</Text>
<details className="rounded-md border border-border px-3 py-2">
<summary className="cursor-pointer text-sm font-medium">View full name</summary>
<Paragraph size="sm" tone="muted" className="mt-2">{projectName}</Paragraph>
</details>
</div>
);
}
Multi-line ellipsis
Limit descriptions to a few lines while keeping an explicit disclosure for the complete copy.
The workspace keeps shared settings, review notes, and delivery history together so a team can understand the current state without opening several separate screens.
Read the full description
The workspace keeps shared settings, review notes, and delivery history together so a team can understand the current state without opening several separate screens.
Three-line Paragraph clamp with a visible disclosure
import { Paragraph } from "@phuctech/ui/components/typography";
const description = "The workspace keeps shared settings, review notes, and delivery history together so a team can understand the current state without opening several separate screens.";
export function Example() {
return (
<div className="grid max-w-lg gap-3">
<Paragraph lineClamp={3}>{description}</Paragraph>
<details className="rounded-md border border-border px-3 py-2">
<summary className="cursor-pointer text-sm font-medium">Read the full description</summary>
<Paragraph size="sm" tone="muted" className="mt-2">{description}</Paragraph>
</details>
</div>
);
}
Inside a Card
Typography composes with existing surfaces, status labels, and actions without adding a new wrapper pattern.
North star migration
Shared delivery workspaceKeep the summary short in the list, then give people a visible path to read the complete project context.
Typography composed inside a Card with Badge and Button
import { Badge } from "@phuctech/ui/components/badge";
import { Button } from "@phuctech/ui/components/button";
import {
Card,
CardContent,
CardFooter,
CardHeader,
} from "@phuctech/ui/components/card";
import { Heading, Paragraph, Text } from "@phuctech/ui/components/typography";
export function Example() {
return (
<Card className="w-full max-w-xl">
<CardHeader>
<div className="flex flex-wrap items-start justify-between gap-3">
<div>
<Heading level={3} size="md">North star migration</Heading>
<Text size="sm" tone="muted">Shared delivery workspace</Text>
</div>
<Badge variant="success">Operational</Badge>
</div>
</CardHeader>
<CardContent>
<Paragraph lineClamp={2} size="sm">
Keep the summary short in the list, then give people a visible path to read the complete project context.
</Paragraph>
</CardContent>
<CardFooter>
<Button size="sm">Open workspace</Button>
</CardFooter>
</Card>
);
}
Heading playground
Try the semantic level, visual size, and display font independently.
Project overview
Interactive Heading configuration
import { Heading } from "@phuctech/ui/components/typography";
export function Example() {
return <Heading level={2} size="lg" font="body">Project overview</Heading>;
}When to use
Use Heading for a named section, Text for short inline or supporting copy, and Paragraph for a complete explanation. The components keep semantic HTML intact while making PhucTech's type scale and tone choices repeatable.
Use truncate only when the surrounding layout has a real width constraint. Use lineClamp for a short preview of a longer description, and provide a visible disclosure such as <details> or a “View more” action when the full content matters.
Usage
import { Heading, Paragraph, Text } from "@phuctech/ui/components/typography";
export function Example() {
return (
<div className="grid gap-3">
<Heading level={2}>Make hierarchy visible</Heading>
<Text tone="muted">A supporting line gives the section a clear starting point.</Text>
<Paragraph>
Paragraph keeps longer explanations readable with the same type scale and semantic color roles.
</Paragraph>
</div>
);
}
Composition
Keep the semantic role in the component and the visual decision in its props. Heading level controls the document outline; size can change its visual scale when a nested region needs a quieter title. Put semantic inline elements such as strong, em, mark, and code inside Text or Paragraph instead of creating a component for every formatting treatment.
A card title can stay an h3 while using a smaller visual size than a page section.
Pair a semantic tone with readable words; success, warning, and danger tones are not status labels by themselves.
API
Tokens
Accessibility
- Choose
Heading levelfrom the page outline, not from the size you want to see. - Keep important meaning in text; a tone or color must never be the only status signal.
- Truncation is visual. Screen readers still receive the full content, and people need a visible way to open or read it when it matters.
- Use native inline semantics:
strongandemfor meaning,sfor no-longer-valid copy,markfor a relevant match, andcodefor code tokens.
Do and don’t
Keep a comfortable reading measure, use sentence case, and show a full-content path next to an ellipsis preview.
Use a giant display treatment for every heading, clamp required instructions, or hide the only copy of a value behind a tooltip.
Related
- Typography foundation documents fonts, scale, leading, and reading measure.
- Card provides a bounded surface where heading and body hierarchy can stay explicit.
- Badge adds a short readable status label next to supporting text.