PPTX
Links
Add hyperlinks to shapes and text for interactive navigation
Add clickable hyperlinks to shapes or text runs for web navigation, email links, or internal slide references.
Hyperlink on a Shape
Make an entire shape clickable:
import { Slide, Shape, Paragraph, TextRun } from "@office-open/pptx";
new Slide({
children: [
new Shape({
x: 1,
y: 1,
width: 4,
height: 1,
text: "Visit our website",
paragraphs: [
new Paragraph({
children: [
new TextRun({ text: "Visit our website", color: "0563C1", underline: {} }),
],
}),
],
hyperlink: {
url: "https://example.com",
tooltip: "Go to example.com",
},
}),
],
});
Hyperlink on Text Run
Apply a hyperlink to a specific portion of text:
new Shape({
x: 1,
y: 1,
width: 6,
height: 3,
paragraphs: [
new Paragraph({
children: [
new TextRun({ text: "For more info, visit " }),
new TextRun({
text: "our documentation",
color: "0563C1",
underline: {},
hyperlink: {
url: "https://docs.example.com",
tooltip: "Open documentation",
},
}),
new TextRun({ text: " for details." }),
],
}),
],
});
Email Link
Use a mailto: URL to create an email hyperlink:
new TextRun({
text: "Contact Support",
color: "0563C1",
underline: {},
hyperlink: {
url: "mailto:support@example.com",
tooltip: "Send email to support",
},
});
Internal Slide Link
Navigate to a specific slide within the presentation:
new Shape({
x: 1,
y: 4,
width: 3,
height: 0.8,
text: "Go to Summary",
hyperlink: {
slide: 3, // Navigate to slide index 3 (0-based)
tooltip: "Jump to summary slide",
},
});
Hyperlink Options
| Property | Type | Description |
|---|---|---|
url | string | External URL or mailto: link |
slide | number | Target slide index (0-based) |
tooltip | string | Tooltip text shown on hover |
Note: Use either
urlorslide, not both.