Horizontal Expand Collapse similar to out of the box UI

I am looking to create a UI where I want to have a section on the right side which can be expanded or collapsed using a image button. Basically similar to out of the box test bed, where you can hide or show rule inputs on the right. 

How do I do that in an interace?

  Discussion posts and replies are publicly visible