# Gradio: How to "Clear" everything w/ Blocks?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-how-to-clear-everything-w-blocks%2F38238%3E%5C
**Category:** 🔒 Gradio\
**Created:** [May 1, 2023, 2:59am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-how-to-clear-everything-w-blocks%2F38238 "2023-05-01T02:59:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![drscotthawley](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/drscotthawley/32/62161_2.png) [@drscotthawley](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdrscotthawley)%5C
**Post date:** [May 1, 2023, 2:59am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-how-to-clear-everything-w-blocks%2F38238%2F1 "2023-05-01T02:59:18Z")

</div>

How can we clear everything on the page, the way the simple interface’s Clear button does it?

I tried adding a button and cycling through all elements and calling `x.clear()` on each one, but it either has no effect or I get errors. I’ve looked all over the docs but can only find an example of clearing a single Chatbot interface. I’ve got multiple audio inputs and text inputs, and such. With the simple interface the Clear button automatically worked. So… how do we implement that?

Thanks.

---

<div class="post-metadata">

**Author:** ![freddyaboulton](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/freddyaboulton/32/32732_2.png) [@freddyaboulton](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ffreddyaboulton)%5C
**Post date:** [May 1, 2023, 2:23pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-how-to-clear-everything-w-blocks%2F38238%2F2 "2023-05-01T14:23:09Z")

</div>

Hi @drscotthawley !

Returning `None` from an event as the value for a component has the same effect as the `Clear` button.

---

<div class="post-metadata">

**Author:** ![drscotthawley](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/drscotthawley/32/62161_2.png) [@drscotthawley](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdrscotthawley)%5C
**Post date:** [May 1, 2023, 4:24pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-how-to-clear-everything-w-blocks%2F38238%2F3 "2023-05-01T16:24:22Z")

</div>

@freddyaboulton Thanks for your reply.  
Ok, I just now tried

```auto
clear_btn.click(lambda: None) 

```

but it had no effect: none of my elements (e.g. Audio inputs) cleared when i pressed the button. Could you please be more specific? Thanks

Here’s more of my code right now:

```python
        inputs = [audio1, textprompt1, audio2, textprompt2, interp_slider, batch_slider,
                        cfg_slider, crossfade_secs, init_audio, init_str_slider]
        outputs = [output_audio, embed_plot]
        wrapper = partial(process_audio, device, verbose=verbose) 

        submit_btn.click(fn=wrapper, inputs=inputs, outputs=outputs)
        clear_btn.click(lambda: None ) 

```

---

<div class="post-metadata">

**Author:** ![freddyaboulton](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/freddyaboulton/32/32732_2.png) [@freddyaboulton](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ffreddyaboulton)%5C
**Post date:** [May 1, 2023, 4:35pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-how-to-clear-everything-w-blocks%2F38238%2F4 "2023-05-01T16:35:24Z")

</div>

Can try via `outputs=outputs` in the `click` method?

---

<div class="post-metadata">

**Author:** ![drscotthawley](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/drscotthawley/32/62161_2.png) [@drscotthawley](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdrscotthawley)%5C
**Post date:** [May 1, 2023, 4:44pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-how-to-clear-everything-w-blocks%2F38238%2F5 "2023-05-01T16:44:42Z")

</div>

@freddyaboulton Sure. I had tried that earlier; `clear_btn.click(lambda: None, outputs=outputs )`

…but was and am still getting the error:

```auto
An event handler didn't receive enough output values (needed: 2, received: 1). Wanted outputs: [audio, plot] Received outputs: [None]

```

Oh, perhpas I need to do `lambda: [None]*2`? …that hadn’t occurred to me.

---

<div class="post-metadata">

**Author:** ![drscotthawley](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/drscotthawley/32/62161_2.png) [@drscotthawley](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdrscotthawley)%5C
**Post date:** [May 1, 2023, 4:46pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-how-to-clear-everything-w-blocks%2F38238%2F6 "2023-05-01T16:46:55Z")

</div>

Ok that works!  
… but when I try it on my Slider items, rather than being restored to their default values, they all get moved all the way to the left. Is there a way to have them reset to the default (“value”) i specified when I setup the Sliders?

---

<div class="post-metadata">

**Author:** ![freddyaboulton](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/freddyaboulton/32/32732_2.png) [@freddyaboulton](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ffreddyaboulton)%5C
**Post date:** [May 1, 2023, 4:53pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-how-to-clear-everything-w-blocks%2F38238%2F7 "2023-05-01T16:53:09Z")

</div>

Yep - needs to be None for each component!

Yes, if you store the default variable in `SLIDER_DEFAULT`, return that instead of None. So if it’s the second element of `outputs`, do something like `clear_btn.click(lambda: [None, 5], outputs=[Audio, Slider])`

---

<div class="post-metadata">

**Author:** ![drscotthawley](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/drscotthawley/32/62161_2.png) [@drscotthawley](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdrscotthawley)%5C
**Post date:** [May 1, 2023, 4:56pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgradio-how-to-clear-everything-w-blocks%2F38238%2F8 "2023-05-01T16:56:11Z")

</div>

Thank you! All done! 🙂
