# How to implement reset button to clear output

**URL:** <https://community.plotly.com/t/how-to-implement-reset-button-to-clear-output/15701>\
**Category:** Dash Python\
**Created:** [November 16, 2018, 7:32am UTC](https://community.plotly.com/t/how-to-implement-reset-button-to-clear-output/15701 "2018-11-16T07:32:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chainster\_mike](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@chainster\_mike](https://community.plotly.com/u/chainster_mike)\
**Post date:** [November 16, 2018, 7:32am UTC](https://community.plotly.com/t/how-to-implement-reset-button-to-clear-output/15701/1 "2018-11-16T07:32:06Z")

</div>

I am trying to implement a reset button to clear input. But I got stuck on: once the reset button is push, I cannot aggregate again. Here is a sample of my idea:

```python
import dash
from dash.dependencies import Input, Output, State
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()
app.layout = html.Div([
    html.Div(id='output'),
    html.Button('Input',id='input_button',n_clicks=0),
    html.Button('Reset',id='reset_button', n_clicks=0),
])

@app.callback(Output('output','children'),
             [Input('input_button','n_clicks'),
              Input('reset_button','n_clicks')])
def update(input_clicks, reset):
    if input_clicks>0 and reset==0:
        return f'there are {input_clicks} input clicks, and {reset} reset_clicks.'
    elif reset>0:
        reset=0
        return 'all clear'
    
app.run_server()

```

I found this thread to be very similar to my [question](https://community.plotly.com/t/how-to-implement-reset-button-for-graph/14202), but couldn’t quite figure out how to do it still. Can someone give me some suggestion?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![caiyij](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/caiyij/32/4462_2.png) [@caiyij](https://community.plotly.com/u/caiyij)\
**Post date:** [November 16, 2018, 6:58pm UTC](https://community.plotly.com/t/how-to-implement-reset-button-to-clear-output/15701/2 "2018-11-16T18:58:49Z")

</div>

Hi mike, hope the code below helps.  
 ![spiraf9fLe](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/0/080e504b27eed88e7fefd226aa2276209538fb6a.gif)

```auto
import dash
from dash.dependencies import Input, Output
import dash_html_components as html

app = dash.Dash()
app.layout = html.Div([
    html.Div(id='output'),
    html.Button('Input',id='input_button',n_clicks=0),
    html.Button('Reset',id='reset_button', n_clicks=0),
], style={'marginTop':20, 'marginLeft':20})

@app.callback(Output('output','children'),
             [Input('input_button','n_clicks')])
def update(input_clicks):
    if input_clicks>0:
        return f'there are {input_clicks} input clicks.'

@app.callback(Output('input_button','n_clicks'),
             [Input('reset_button','n_clicks')])
def update(reset):
    return 0

if __name__ == ' __main__':
    app.run_server(debug=True)

```

---

<div class="post-metadata">

**Author:** ![chainster\_mike](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@chainster\_mike](https://community.plotly.com/u/chainster_mike)\
**Post date:** [November 17, 2018, 12:48am UTC](https://community.plotly.com/t/how-to-implement-reset-button-to-clear-output/15701/3 "2018-11-17T00:48:57Z")

</div>

Thank you! This is very helpful. I didn’t know that the button itself can be the destination of a output, so your example will be very useful for me.

---

<div class="post-metadata">

**Author:** ![dem26](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@dem26](https://community.plotly.com/u/dem26)\
**Post date:** [November 11, 2020, 9:48am UTC](https://community.plotly.com/t/how-to-implement-reset-button-to-clear-output/15701/4 "2020-11-11T09:48:49Z")

</div>

I really love this solution, as I’m having a similar issue. However I’m having trouble as I have multiple ‘reset’ buttons (same id, using pattern matching callbacks). Do you have any idea as to what I would return to make this work for multiple ‘reset’ buttons?
