Expose full gradient fill definitions for shapes in the PowerPoint JavaScript API (read and write)
Context
I am building a PowerPoint add-in that enforces consistent corporate design by applying predefined styles from a centrally managed custom library (for example, gradient presets for specific object types). The add-in must be able to inspect existing shapes to detect deviations from the defined style and to apply the correct gradient styling back to shapes.
This differs from PowerPoint’s out-of-the-box “Format Painter” / “copy-paste format” workflows because the style definitions are stored uniformly in the add-in and can be applied across any presentation without requiring that a “reference shape” with the desired formatting exists in the current deck.
Pain
The current PowerPoint JavaScript API does not provide access to gradient details on shape fills. While a shape’s fill type may indicate a gradient, there is no API to:
- Read gradient definition details (linear/path type, direction/angle, stops, stop positions, per-stop colors, per-stop transparency, theme color references, etc.)
- Write or update gradient definitions (set angle, add/remove stops, set stop positions, set colors, set alpha/transparency per stop)
As a result, add-ins cannot implement reliable style sets and enforce application. The only workaround is OOXML parsing and round-tripping slides, which is complex, error-prone, and not feasible for real-time formatting workflows.
Example
Imagine a design system defines a “Primary Accent Gradient” used across shapes in many presentations:
- Linear gradient at 45 degrees
- Three stops at 0%, 60%, 100%
- Specific colors and transparency per stop
A user selects multiple shapes and triggers “Apply Primary Accent Gradient” from the add-in’s style library.
With the current API:
- The add-in cannot read the existing gradient definition to determine whether shapes comply with the design system.
- The add-in cannot set the target gradient definition precisely (stops, positions, direction, transparency).
- The add-in cannot store and reapply gradient styles consistently across presentations because gradients cannot be expressed as a reusable, structured object via the API.
Request
Please extend the PowerPoint JavaScript API to support full gradient manipulation for shape fills, both reading and writing, similar in capability to what is available in the PowerPoint UI.
A possible API surface (illustrative) could include:
Read gradient definitions on a shape fill, for example:
- shape.fill.gradient (nullable; available if shape.fill.type === Gradient)
- shape.fill.gradient.type (linear/path)
- shape.fill.gradient.angle (for linear gradients)
- shape.fill.gradient.stops: GradientStop[] with:
- position (0..1 or 0..100)
- color (RGB/hex and optionally theme reference)
- transparency or alpha
Write/apply gradient definitions, for example:
- shape.fill.setGradient(gradient: GradientFill)
- shape.fill.gradient.stops.add(...), remove(...), clear()
- shape.fill.gradient.angle = ...
Optional convenience methods for consistent styling scenarios, for example:
- shape.fill.applyFillStyle(fillStyleId: string) or a similar concept if Microsoft plans broader style primitives.
This would enable add-ins to:
- Audit slides for gradient compliance
- Apply centrally stored gradient presets across any presentation
- Enforce consistent visual design at scale without relying on manual format copying or a reference shape present in the deck
This feature would improve the viability of professional formatting add-ins for PowerPoint.