Use expressions to set object properties (e.g. size)

I want to use an expression to set the width of an object so it matches the width of another object. I imagine it to work like this: In the width property: = width of [layer]

The concrete use case looks as such:
For a library component in its loading state, the text is replaced with a skeleton (an animated gradient). Auto-layout doesn’t allow me to keep the width of the default state - that is determined by the text layer (hug) – when switching to the loading variant.

I hacked a solution with setting the layer opacity to 0% on the text layer and setting layer constraints to scale on the skeleton. I’d still like to set the size relationship “programatically”.