JSFiddle - React, Tailwind, and code Playground

HTML

<a href="#">Toggle</a>

<a href="#" class='openA'>OPEN</a>
<a href="#" class='closeA'>CLOSE</a>

<p>Hello</p>

CSS

p {
    height: 100px;
    width: 100px;
    background: red;}

JavaScript

$("a").toggle(
  function () {
      $('p').animate({width: "200px"});
  },
  function () {
    $('p').animate({width: "100px"});
  }
);


$("a.openA").click(function() {
    $('p').stop().animate({width: "200px"});
});


$("a.closeA").click(function() {
    $('p').stop().animate({width: "100px"});
});