UMG widget collapse animation

You can use Widget Animation to achieve that effect
WidgetAnimation

Lets say I have a vertical box containing a couple of random height panels. And I’d like to click on the header of the panel to collapse it with animation (hide its contents and leave only header). Is there any way to do so? I can collapse it hard with visibility options, but it happens abruptly. I would like the collapsed panel to shrink gradually and other panels below to slide smoothly to their new position.

A good example is web element known as accordion. It has collapsable panels with random content inside. Where should I dig to get what I want? Is there any example of that element behaviour made on UMG anyway?

Widget Animations do not support variables. For example I have one panel with 10 lines of text in it, and another one with 20 lines. Both panels made from one widget. I can create an animation for collapsing 10 lines, or another animation for 20 lines (they would have different transform values on keyframes). But how would I make it generic animation that would work with any number of lines?

That’s the first problem. The other one is that until the visibility option is not set to Collapse the bounding box of the widget stays the same as it was before the animation. So there will be empty space between the panel collapsed by animation and the next one in vertical box (for example). Is there a workaround? Can I shrink the bounding box along with animation?

Good luck on your project.