a:fill (Shape Fill Properties)
Container element for shape fill properties in DrawingML, allowing specification of solid, gradient, pattern, picture, or group fills.
Child elements
Description
a:fill is a container element that specifies the fill properties for a DrawingML shape, text body, or group. It is defined in ECMA-376 Part 1 §20.1.2.3 and serves as the parent element for various fill type options.
A shape’s fill defines how its interior surface is colored or patterned. Office Open XML provides several fill options:
- Solid fill (
a:solidFill): Uniform color across the shape - Gradient fill (
a:gradFill): Smooth color transition - Pattern fill (
a:pattFill): Predefined pattern with foreground/background colors - Picture/Blip fill (
a:blipFill): Image-based fill - Group fill (
a:grpFill): Inherits fill from parent group - No fill (
a:noFill): Transparent/unfilled shape
Exactly one child element must be present to specify the fill type.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
| (none) | — | — | a:fill has no attributes; the fill type is determined by its child element. |
Examples
Shape with Solid Fill
<a:spPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="914400" cy="914400"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
<a:fill>
<a:solidFill>
<a:srgbClr val="00AAFF"/>
</a:solidFill>
</a:fill>
</a:spPr>
using DocumentFormat.OpenXml.Drawing;
var shapeProperties = new ShapeProperties();
shapeProperties.Append(new Transform2D());
shapeProperties.Append(new PresetGeometry { Preset = PresetGeometryValues.Rectangle });
shapeProperties.Append(new SolidFill(
new RgbColorModelHex { Val = "00AAFF" }
));
Shape with No Fill (Transparent)
<a:fill>
<a:noFill/>
</a:fill>
var fill = new NoFill();
Shape with Gradient Fill
<a:fill>
<a:gradFill>
<a:gsLst>
<a:gs pos="0">
<a:srgbClr val="FF0000"/>
</a:gs>
<a:gs pos="100000">
<a:srgbClr val="0000FF"/>
</a:gs>
</a:gsLst>
<a:lin ang="2700000" scaled="1"/>
</a:gradFill>
</a:fill>
var gradFill = new GradientFill();
var gsLst = new GradientStopList();
gsLst.Append(new GradientStop { Position = 0 }
{ Children = new[] { new RgbColorModelHex { Val = "FF0000" } } });
gsLst.Append(new GradientStop { Position = 100000 }
{ Children = new[] { new RgbColorModelHex { Val = "0000FF" } } });
gradFill.Append(gsLst);
gradFill.Append(new LinearGradientFill { Angle = 2700000, Scaled = true });
Notes
- Exactly one child fill element must be present (solid, gradient, pattern, blip, group, or no-fill).
- If multiple fill elements are specified, only the first valid one is applied by consumer applications.
- Shape fills are inherited by child elements in grouped shapes unless explicitly overridden.
- Use
a:noFillfor transparent shapes that show content behind them.