SVG Filter primitiveUnits Attribute Guide

The primitiveUnits attribute on an SVG <filter> element defines the coordinate system and units used for geometric properties within its filter primitives. By setting this attribute, developers determine whether dimensions and positions—such as x, y, width, and height inside primitives like <feGaussianBlur> or <feOffset>—are calculated relative to the entire coordinate space or to the bounding box of the target element.

Supported Values for primitiveUnits

The primitiveUnits attribute accepts two standard values:

1. userSpaceOnUse (Default)

When primitiveUnits is set to userSpaceOnUse (or omitted, as it is the default), all coordinate and length values inside the filter primitives are resolved using the current user coordinate system established when the filter is referenced.

2. objectBoundingBox

When primitiveUnits is set to objectBoundingBox, all coordinates and dimensions within the filter primitives are resolved relative to the bounding box of the graphic element referencing the filter.

Summary of Differences