My WebDev knowledge is quite poor but it seems natural to me that if you have slack-like sidebars, where they tend to be optional but non-temporary, the ideal solution would be 2 css-grids, and a way to switch between them. Even if it were temporary, like a shop using a sidebar for its menu , it still seems intuitively the preferred solution. Essentially just flipping between grid-states.
This is assuming you're actually dealing with a grid, and not some kind of floating pop-over panel eg a drop-down menu panel
How would you go about it? Maybe more importantly, how would you want to go about it?