# Add 'onclick' to Dash html buttons in python

**URL:** <https://community.plotly.com/t/add-onclick-to-dash-html-buttons-in-python/4837>\
**Category:** 📊 Plotly Python\
**Created:** [July 7, 2017, 5:17pm UTC](https://community.plotly.com/t/add-onclick-to-dash-html-buttons-in-python/4837 "2017-07-07T17:17:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ekee](https://avatars.discourse-cdn.com/v4/letter/e/a3d4f5/32.png) [@ekee](https://community.plotly.com/u/ekee)\
**Post date:** [July 7, 2017, 5:17pm UTC](https://community.plotly.com/t/add-onclick-to-dash-html-buttons-in-python/4837/1 "2017-07-07T17:17:14Z")

</div>

I need to add an onclick event to an html button I’ve created, but while the standard dash html library includes buttons, it does not allow for ‘onclick’ as an argument. Where does dash compile the ‘pythonhtml’ to actual html so I can go in and add this functionality. I’ve already added ‘onclick’ as an option in dash\_html\_components in metadeta.json and bundle.js

---

<div class="post-metadata">

**Author:** ![syrup](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@syrup](https://community.plotly.com/u/syrup)\
**Post date:** [August 9, 2021, 3:37pm UTC](https://community.plotly.com/t/add-onclick-to-dash-html-buttons-in-python/4837/2 "2021-08-09T15:37:31Z")

</div>

@ekee Did you ever figure this out? There are similar questions all over the forum with no answers.

---

<div class="post-metadata">

**Author:** ![adithiyan](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/adithiyan/32/21686_2.png) [@adithiyan](https://community.plotly.com/u/adithiyan)\
**Post date:** [November 30, 2022, 4:29am UTC](https://community.plotly.com/t/add-onclick-to-dash-html-buttons-in-python/4837/3 "2022-11-30T04:29:09Z")

</div>

me too i don’t know how can I add onclick trigger for calling a javascript function in plotly dash

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 1, 2022, 5:57am UTC](https://community.plotly.com/t/add-onclick-to-dash-html-buttons-in-python/4837/4 "2022-12-01T05:57:10Z")

</div>

Hello @adithiyan,

You can add a clientside callback,

```auto
app.clientside_callback(
‘’’
function (n1) {
     myfunction()
     return window.dash_clientside.no_update
}’’’,
Output(‘button’,’n_clicks’),
Input(‘button’,’n_clicks’)

)

```

Where myfunction represents your targeted function.
