SmartArt
Use smartart to add SmartArt graphics — predefined diagram layouts for visualizing processes, hierarchies, relationships, and more.
Basic SmartArt
import { generatePresentation } from "@office-open/pptx";
{
"slides": [
{
"children": [
{
"smartart": {
"x": "1.3cm",
"y": "1.3cm",
"width": "21.2cm",
"height": "9.3cm",
"layout": "default",
"style": "simple1",
"color": "accent1_2",
"nodes": [{ "text": "Step 1" }, { "text": "Step 2" }, { "text": "Step 3" }]
}
}
]
}
]
}
{
children: [
{
smartart: {
x: "1.3cm",
y: "1.3cm",
width: "21.2cm",
height: "9.3cm",
layout: "default",
style: "simple1",
color: "accent1_2",
nodes: [
{ text: "Step 1" },
{ text: "Step 2" },
{ text: "Step 3" },
],
},
},
],
}
Nested Nodes
Nodes support nested children for hierarchical data:
{
"slides": [
{
"children": [
{
"smartart": {
"x": "1.3cm",
"y": "1.3cm",
"width": "21.2cm",
"height": "11.6cm",
"layout": "default",
"nodes": [
{ "text": "Item A", "children": [{ "text": "Sub A1" }, { "text": "Sub A2" }] },
{ "text": "Item B", "children": [{ "text": "Sub B1" }] },
{ "text": "Item C" }
]
}
}
]
}
]
}
{
children: [
{
smartart: {
x: "1.3cm",
y: "1.3cm",
width: "21.2cm",
height: "11.6cm",
layout: "default",
nodes: [
{
text: "Item A",
children: [{ text: "Sub A1" }, { text: "Sub A2" }],
},
{
text: "Item B",
children: [{ text: "Sub B1" }],
},
{ text: "Item C" },
],
},
},
],
}
Styling SmartArt
Control the visual style and color scheme:
{
"slides": [
{
"children": [
{
"smartart": {
"x": "1.3cm",
"y": "1.3cm",
"width": "21.2cm",
"height": "9.3cm",
"layout": "process1",
"nodes": [{ "text": "Phase 1" }, { "text": "Phase 2" }, { "text": "Phase 3" }],
"color": "accent2_1",
"style": "simple1"
}
}
]
}
]
}
{
children: [
{
smartart: {
x: "1.3cm",
y: "1.3cm",
width: "21.2cm",
height: "9.3cm",
layout: "process1",
nodes: [{ text: "Phase 1" }, { text: "Phase 2" }, { text: "Phase 3" }],
color: "accent2_1", // Color scheme
style: "simple1", // Visual style
},
},
],
}
SmartArt Options
| Option | Type | Description |
| -------- | ------------ | ------------------------------------------------------ | ------------------- |
| x | number | UniversalMeasure | Horizontal position |
| y | number | UniversalMeasure | Vertical position |
| width | number | UniversalMeasure | Width |
| height | number | UniversalMeasure | Height |
| layout | string | Layout ID (e.g. "default", "process1") |
| style | string | Quick style ID (e.g. "simple1", "moderate1") |
| color | string | Color transform ID (e.g. "accent1_2", "colorful1") |
| nodes | TreeNode[] | Array of { text, children? } objects |