import gradio as gr with gr.Blocks() as demo: with gr.Row(): with gr.Column(visible=False, min_width=200, scale=0) as sidebar: btn1 = gr.Button("Button 1") btn2 = gr.Button("Button 2") with gr.Column() as main: open_sidebar_btn = gr.Button("Open Sidebar", scale=0) close_sidebar_btn = gr.Button("Close Sidebar", visible=False, scale=0) open_sidebar_btn.click(lambda: { open_sidebar_btn: gr.Button(visible=False), close_sidebar_btn: gr.Button(visible=True), sidebar: gr.Column(visible=True) }, outputs={open_sidebar_btn, close_sidebar_btn, sidebar}) close_sidebar_btn.click(lambda: { open_sidebar_btn: gr.Button(visible=True), close_sidebar_btn: gr.Button(visible=False), sidebar: gr.Column(visible=False) }, outputs={open_sidebar_btn, close_sidebar_btn, sidebar}) gr.Markdown("# Hello Blocks") gr.Markdown("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam nec nulla nec nulla fermentum fermentum. Nullam nec nulla nec nulla fermentum fermentum.") demo.launch()