JSFiddle - React, Tailwind, and code Playground

HTML

<button class='toggle-button switch-on'>Test</button>
<div id="color-list">Container Contents</div>

CSS

#color-list{display:none;}

JavaScript

$(document).ready(function(){ 


    $('.toggle-button').on('click', 
                           function(event){
                               toggleVisibility(this,'color-list');
                               event.preventDefault();
                           });
    
    function toggleVisibility(caller,elementId)
    {
        if($(caller).hasClass('switch-off')){
    
    $(caller).removeClass('switch-off');

    $(caller).addClass('switch-on');

    $('#'+elementId).hide();
    }
    else{

        $(caller).removeClass('switch-on');

        $(caller).addClass('switch-off');

       $('#'+elementId).show();
}
    }
    
});