CSSTransformComponent: toString() method
Baseline 2026>
Newly available
Since November 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Want more browser support for this feature? Tell us why.
Note: This feature is available in Web Workers.
The toString() method of the CSSTransformComponent interface is a stringifier returning a CSS Transforms function.
Syntax
js
toString()
Parameters
None.
Return value
A string in the form of a CSS transform function.
This will use the value of is2D to return either a 2D or 3D transform.
For example, if the component represents CSSRotate and is2D is false, then the string returned will be in the form of the CSS transformation rotate3d() function.
If true the string returned will be in the form of the 2-dimensional rotate() function.
Examples
>Serializing 2D and 3D components
js
const translate2D = new CSSTranslate(CSS.px(10), CSS.px(20));
console.log(translate2D.toString()); // "translate(10px, 20px)"
const translate3D = new CSSTranslate(CSS.px(10), CSS.px(20), CSS.px(30));
console.log(translate3D.toString()); // "translate3d(10px, 20px, 30px)"
Specifications
| Specification |
|---|
| CSS Typed OM Level 1> # CSSTransformComponent-stringification-behavior> |