# Reset to Initial state without reloading page

**URL:** <https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978>\
**Category:** Dash Python\
**Created:** [July 18, 2017, 6:31pm UTC](https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978 "2017-07-18T18:31:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![raghunath](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@raghunath](https://community.plotly.com/u/raghunath)\
**Post date:** [July 18, 2017, 6:31pm UTC](https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978/1 "2017-07-18T18:31:43Z")

</div>

I was wondering how to go about having a ‘Reset’ button which when clicked will reset the app state to the initial state without having to reload the webpage.

Any ideas?.

---

<div class="post-metadata">

**Author:** ![Sherm4nLC](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/sherm4nlc/32/1322_2.png) [@Sherm4nLC](https://community.plotly.com/u/Sherm4nLC)\
**Post date:** [July 19, 2017, 7:46am UTC](https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978/2 "2017-07-19T07:46:59Z")

</div>

Have you noticed these two buttons here for doing Undo and Redo?  
Is that something similar to what you are after?  
Otherwise I can imagine you can manipulate the value of your input widgets with a button that sets them to a default.

![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/8/8a8f033f68aae479bc4723b463994b33b6277918.png)

---

<div class="post-metadata">

**Author:** ![will](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@will](https://community.plotly.com/u/will)\
**Post date:** [July 19, 2017, 8:10am UTC](https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978/3 "2017-07-19T08:10:35Z")

</div>

I have a similar use case. I have about four groups of radio buttons, and ensure each group’s default is “Any” or “All”. In the callback, I just make sure to check for this:

```
if rad and rad != 'Any':
   #manipulate data here
```

---

<div class="post-metadata">

**Author:** ![raghunath](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@raghunath](https://community.plotly.com/u/raghunath)\
**Post date:** [July 19, 2017, 9:18am UTC](https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978/4 "2017-07-19T09:18:36Z")

</div>

Similar to Undo/Redo buttons but all the way to initial state instead of just one state back or forward.

I have no idea how to reset the values of my input widgets to default. If you have done this, can you share an example.

---

<div class="post-metadata">

**Author:** ![Sherm4nLC](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/sherm4nlc/32/1322_2.png) [@Sherm4nLC](https://community.plotly.com/u/Sherm4nLC)\
**Post date:** [July 19, 2017, 3:19pm UTC](https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978/5 "2017-07-19T15:19:40Z")

</div>

I hope this explains what I meant before

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

app = dash.Dash()

app.css.append_css({
    "external_url": "https://codepen.io/chriddyp/pen/bWLwgP.css"
})

app.layout = html.Div(children=[
    html.Div(children=[
    html.H4(children='Example Dash'),
    
    
    html.Div(id='div_row1',children=[
    
        # Div Retention
        html.Div(id='div', children=[
            html.P("Retention"),
            html.Button('Default Values', id='default_values'),
            dcc.Dropdown(
            id="sel_01",
            options=[
                {'label': 'True', 'value': True},
                {'label': 'False', 'value': False}

            ],
            value=False,
            multi=False
            ),
            dcc.Dropdown(
            id="sel_02",
            options=[
                {'label': 'True', 'value': True},
                {'label': 'False', 'value': False}

            ],
            value=False,
            multi=False
            ),
            html.P(id="p1",children=["placeholder"])
        ], className='six columns')

    ]),
    dcc.Interval(
        id='interval-component',
        interval=5*60*1000 # in milliseconds
    )
    ]),
    ])

@app.callback(
    Output(component_id='sel_01', component_property='value'),
    events=[Event('default_values', 'click')])
def update():
    return False

@app.callback(
    Output(component_id='sel_02', component_property='value'),
    events=[Event('default_values', 'click')])
def update():
    return False

@app.callback(
    Output(component_id='p1', component_property='children'),
    [Input(component_id='sel_01', component_property='value'),
    Input(component_id='sel_02', component_property='value')])
def update(val_1, val_2):
    return "text: "+str(val_1)+str(val_2)

if __name__ == ' __main__':
    app.run_server(debug=True, host='0.0.0.0', port=5091)
```

---

<div class="post-metadata">

**Author:** ![raghunath](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@raghunath](https://community.plotly.com/u/raghunath)\
**Post date:** [July 19, 2017, 6:10pm UTC](https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978/6 "2017-07-19T18:10:30Z")

</div>

Excellent. That’s exactly what I’m looking for. Thanks a lot.

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [July 19, 2017, 6:52pm UTC](https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978/7 "2017-07-19T18:52:06Z")

</div>

Great example @Sherm4nLC, thank you!

I like these kind of solutions that use the dash interface itself.

I could imagine that we include a (customizable) “Dash Toolbar” by default that includes these types of features: Undo, Redo, Reset. If anyone would like to see Reset as a native, default-on feature, please speak up!

---

<div class="post-metadata">

**Author:** ![raghunath](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@raghunath](https://community.plotly.com/u/raghunath)\
**Post date:** [July 19, 2017, 7:19pm UTC](https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978/8 "2017-07-19T19:19:20Z")

</div>

Absolutely, would love to have this feature. I can envision many situations where ‘Reset’ button could be useful to reset individual components of the app or all the components of the app.

---

<div class="post-metadata">

**Author:** ![PJan](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/pjan/32/4492_2.png) [@PJan](https://community.plotly.com/u/PJan)\
**Post date:** [October 20, 2018, 8:02pm UTC](https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978/9 "2018-10-20T20:02:34Z")

</div>

Absolutely, I’m fetching input data from Bars to manipulate a scatter plot but after doing that I want it to reset itself and get back to initial theme of manipulating scatter graph from input of the dropdown menu when changed value.

---

<div class="post-metadata">

**Author:** ![Uzor](https://avatars.discourse-cdn.com/v4/letter/u/13edae/32.png) [@Uzor](https://community.plotly.com/u/Uzor)\
**Post date:** [December 1, 2020, 8:44am UTC](https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978/11 "2020-12-01T08:44:19Z")

</div>

Just as @raghunath mentioned, I am in a situation where I have to reset all the app components without having to refresh the page.

---

<div class="post-metadata">

**Author:** ![andyshirey](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@andyshirey](https://community.plotly.com/u/andyshirey)\
**Post date:** [January 5, 2021, 11:48pm UTC](https://community.plotly.com/t/reset-to-initial-state-without-reloading-page/4978/12 "2021-01-05T23:48:16Z")

</div>

> [@Sherm4nLC](#):
>
> `from dash.dependencies import Input, Output, Event`

dash.dependencies no longer supports ‘Event,’ but it’s possible to solve this using html.Button (or dbc.Button if you use dash\_bootstrap\_comopnents) by using a button’s ‘n\_clicks’ in lieu of an Event click, then sticking with the same workflow otherwise (in @Sherm4nLC’s example above, returning False as the output of the Button click’s callback and feeding that output to component\_id=‘sel\_01’ and ‘sel\_02’).
