JSFiddle - React, Tailwind, and code Playground

HTML

<div id="wrapper">
    <div id="box1" class="expand"></div>
    <div id="box2" class="expand collapse"></div>
    <div id="box3" class="expand collapse"></div>
</div>

CSS

#wrapper {
    height: 500px;
    display: flex;
    flex-direction: column;
}

.expand {
    flex: 1 1 auto;
    transition: all 2s;
}

.collapse {
    flex: 0 1 25px;
}

#box1 {
    background-color: yellow;
}

#box2 {
    background-color: green;
}

#box3 {
    background-color: blue;
}

JavaScript

$('.expand').click(function() {
  var expandId = $(this).attr('id');
    $('.expand').each(function() {
        var thisId = $(this).attr('id');
        if (expandId != thisId) {
            $('#' + thisId).addClass('collapse');
        } else {
            $('#' + thisId).removeClass('collapse');
        }
    });
  });