This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The baseVal read-only property of the SVGAnimatedRect interface represents the current non-animated value of the viewBox attribute of an SVG element.
This property reflects the SVG element's viewBox attribute value as a read-only DOMRect object. It provides access to the static rectangle defined by the viewBox attribute, including the x, y, width, and height values.
A DOMRect object representing the current non-animated value of the viewBox attribute.
<svg viewBox="0 0 200 100" id="mySvg"> <rect width="100" height="100" fill="blue" /> </svg>
const svgElement = document.getElementById("mySvg");
const animatedRect = svgElement.viewBox.baseVal;
// Access the non-animated base value
console.log(animatedRect.x); // 0
console.log(animatedRect.y); // 0
console.log(animatedRect.width); // 200
console.log(animatedRect.height); // 100
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
baseVal |
1 | 12 | 15 | ≤12.1 | 3 | 18 | 15 | ≤12.1 | 1 | 1.0 | 3 | 1 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SVGAnimatedRect/baseVal