Skip to content
Office Open

PPTX

Styles and Themes

Apply color schemes, theme colors, and consistent styling across slides

Apply consistent styling across your presentation using fills, outlines, and color schemes.

#Solid Fill on Shapes

ts
import { generatePresentation } from "@office-open/pptx";
JSON
{
  "slides": [
    {
      "children": [
        {
          "shape": {
            "x": "1.3cm",
            "y": "1.3cm",
            "width": "13.2cm",
            "height": "5.3cm",
            "textBody": {
              "paragraphs": [
                {
                  "children": [
                    {
                      "text": "Blue background",
                      "fill": "FFFFFF",
                      "size": 20
                    }
                  ]
                }
              ]
            },
            "properties": {
              "fill": {
                "type": "solid",
                "color": "2E74B5"
              }
            }
          }
        }
      ]
    }
  ]
}

#Gradient Fill

Linear gradient with angle:

JSON
{
  "slides": [
    {
      "children": [
        {
          "shape": {
            "x": "1.3cm",
            "y": "1.3cm",
            "width": "15.9cm",
            "height": "6.6cm",
            "properties": {
              "fill": {
                "type": "gradient",
                "stops": [
                  {
                    "position": 0,
                    "color": "0D47A1"
                  },
                  {
                    "position": 50,
                    "color": "1976D2"
                  },
                  {
                    "position": 100,
                    "color": "42A5F5"
                  }
                ],
                "angle": 45
              }
            }
          }
        }
      ]
    }
  ]
}

Path gradient (radial):

JSON
{
  "slides": [
    {
      "children": [
        {
          "shape": {
            "x": "1.3cm",
            "y": "1.3cm",
            "width": "10.6cm",
            "height": "10.6cm",
            "properties": {
              "geometry": "ellipse",
              "fill": {
                "type": "gradient",
                "stops": [
                  {
                    "position": 0,
                    "color": "FFFFFF"
                  },
                  {
                    "position": 100,
                    "color": "1565C0"
                  }
                ],
                "path": "circle"
              }
            }
          }
        }
      ]
    }
  ]
}

#No Fill (Transparent)

JSON
{
  "slides": [
    {
      "children": [
        {
          "shape": {
            "x": "1.3cm",
            "y": "1.3cm",
            "width": "13.2cm",
            "height": "5.3cm",
            "properties": {
              "fill": {
                "type": "none"
              },
              "outline": {
                "color": "2E74B5",
                "width": 2
              }
            }
          }
        }
      ]
    }
  ]
}

#Outline

JSON
{
  "slides": [
    {
      "children": [
        {
          "shape": {
            "x": "1.3cm",
            "y": "1.3cm",
            "width": "13.2cm",
            "height": "6.6cm",
            "properties": {
              "fill": {
                "type": "solid",
                "color": "E3F2FD"
              },
              "outline": {
                "color": "1565C0",
                "width": 2
              }
            }
          }
        }
      ]
    }
  ]
}

#Color Scheme Tips

Define a consistent palette and reuse it:

ts
import { generatePresentation } from "@office-open/pptx";

const colors = {
  primary: "2E74B5",
  secondary: "70AD47",
  accent: "ED7D31",
  dark: "1F3864",
  light: "D6E4F0",
  white: "FFFFFF",
};

generatePresentation({
  slides: [
    {
      children: [
        {
          shape: {
            x: "1.3cm",
            y: "1.3cm",
            width: "13.2cm",
            height: "5.3cm",
            properties: {
              fill: { type: "solid", color: colors.primary },
            },
            textBody: {
              paragraphs: [
                {
                  children: [{ text: "Title", fill: colors.white, bold: true, size: 24 }],
                },
              ],
            },
          },
        },
      ],
    },
  ],
});

#Background Styles

Apply background styling at the slide level:

JSON
{
  "slides": [
    {
      "background": {
        "fill": "1F3864"
      },
      "children": []
    }
  ]
}
JSON
{
  "slides": [
    {
      "background": {
        "fill": {
          "type": "gradient",
          "stops": [
            {
              "position": 0,
              "color": "0D47A1"
            },
            {
              "position": 100,
              "color": "42A5F5"
            }
          ],
          "angle": 135
        }
      },
      "children": []
    }
  ]
}