# Is there a way to clear a dropdown from a callback?

**URL:** <https://community.plotly.com/t/is-there-a-way-to-clear-a-dropdown-from-a-callback/72468>\
**Category:** Dash Python\
**Created:** [February 9, 2023, 4:04am UTC](https://community.plotly.com/t/is-there-a-way-to-clear-a-dropdown-from-a-callback/72468 "2023-02-09T04:04:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hrose33](https://avatars.discourse-cdn.com/v4/letter/h/e79b87/32.png) [@hrose33](https://community.plotly.com/u/hrose33)\
**Post date:** [February 9, 2023, 4:04am UTC](https://community.plotly.com/t/is-there-a-way-to-clear-a-dropdown-from-a-callback/72468/1 "2023-02-09T04:04:34Z")

</div>

I have quite a few dropdowns, some with set values from the beginning while others just have placeholder values (i.e. ‘Select X’). I have another button that resets all of the dropdowns but the value within the dropdown remains the same. For example, if I have a dropdown that is selecting fruits and the user selects apples to filter the data, and then they reset the filters (which clears all filters and would change the selected\_fruit = None) the ‘apple’ would still remain in the dropdown box instead of the original placeholder.

TL;DR I want to have my callback clear my dropdown or reset it to the placeholder.

---

<div class="post-metadata">

**Author:** ![hoatran](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/hoatran/32/21447_2.png) [@hoatran](https://community.plotly.com/u/hoatran)\
**Post date:** [February 9, 2023, 5:04am UTC](https://community.plotly.com/t/is-there-a-way-to-clear-a-dropdown-from-a-callback/72468/2 "2023-02-09T05:04:38Z")

</div>

I think return `value=[]` in call back would work. Something as below:

```auto
from dash import Dash, dcc, html, Input, Output
from plotly.express import data
import pandas as pd

df = data.medals_long()

app = Dash( __name__ , external_stylesheets=[dbc.themes.LUX])
app.layout = dbc.Container([
    dbc.Row([
        dbc.Col([
            dcc.Dropdown(df.nation.unique(), 
                         id='pandas-dropdown-2',
                         clearable=True,placeholder='Please select'),
        ],width={'size':10}),
        dbc.Col([
            dbc.Button("Clear",id='btn'),
        ],width={'size':2}),
    ])
])

@app.callback(
    Output('pandas-dropdown-2', 'value'),
    Input('btn', 'n_clicks')
)
def update_value(n_clicks):
    if n_clicks > 1:
        return []

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

```

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [February 21, 2023, 7:59pm UTC](https://community.plotly.com/t/is-there-a-way-to-clear-a-dropdown-from-a-callback/72468/4 "2023-02-21T19:59:10Z")

</div>

Maybe an [MRE](https://community.plotly.com/t/how-to-write-a-minimal-reproducible-example-mre/61502) would help in this case.
