# Extending dash components

**URL:** <https://community.plotly.com/t/extending-dash-components/32088>\
**Category:** Dash Python\
**Created:** [December 2, 2019, 8:29am UTC](https://community.plotly.com/t/extending-dash-components/32088 "2019-12-02T08:29:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [December 2, 2019, 8:29am UTC](https://community.plotly.com/t/extending-dash-components/32088/1 "2019-12-02T08:29:27Z")

</div>

The current documentation on plugins covers creating new Dash components from scratch nicely,

[https://dash.plot.ly/plugins](https://dash.plot.ly/plugins)

Though i am not very familiar with JS, i was able to cook up a few simple ones myself (a go-to-link component, an image toggle element, …). Now, i am facing a scenario where one of the current dash components is close to what i need, but needs some modification. Hence i was thinking that the easiest way to accomplish my goal would be to extend that component and add/overrride functionality as needed.

Is there any documentation and/or examples available for this kind of use case? I guess i would need to import the dash core components somehow 🙂

---

<div class="post-metadata">

**Author:** ![wbrgss](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/wbrgss/32/3621_2.png) [@wbrgss](https://community.plotly.com/u/wbrgss)\
**Post date:** [December 2, 2019, 4:25pm UTC](https://community.plotly.com/t/extending-dash-components/32088/2 "2019-12-02T16:25:54Z")

</div>

Hi @Emil,

That’s a good idea! I made an issue for your suggestion here: [https://github.com/plotly/dash-docs/issues/719](https://github.com/plotly/dash-docs/issues/719). If you end up developing a new functionality or fixing a bug, I’d encourage you to make a pull request on the relevant repository (e.g. [dash-core-components](https://github.com/plotly/dash-core-components)).

---

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [December 30, 2019, 1:03pm UTC](https://community.plotly.com/t/extending-dash-components/32088/3 "2019-12-30T13:03:38Z")

</div>

@wbrgss Thanks for creating the issue. Since i was not able to figure out any smart way to extend a dash component, i ended up with the following process,

- Fork dash-core-components
- Clone the repository and install dependencies as per README.md
- Duplicate the .react.js file of the component which is to be extended in src/components and do the desired changes (including a new component name)
- Add the new component in src/index.js
- Add (any) custom css files to src/components/css
- Bump version number in package.json to X.Y.Z
- Run “npm run build” to build the new component(s)
- Run “python setup.py sdist” to create a package .tar.gz file
- Copy the .tar.gz file to the lib folder my other project(s)
- Add ./lib/dash-core-components-X.Y.Z to requirements.txt of the other project(s)
- Run “pip install -r requirements.txt” for the other project(s)

While this approach is relatively straight forward (and works), it has a few drawbacks

- I duplicate all code of the component, which i am extending
- I need to update and rebuild the whole dash-core-components library each time i make a change to my component and/or a new dash version is released

If anyone can come up with a cleaner solution, i am all ears 🙂

---

<div class="post-metadata">

**Author:** ![hhoeflin](https://avatars.discourse-cdn.com/v4/letter/h/ba9def/32.png) [@hhoeflin](https://community.plotly.com/u/hhoeflin)\
**Post date:** [April 24, 2021, 7:55pm UTC](https://community.plotly.com/t/extending-dash-components/32088/4 "2021-04-24T19:55:48Z")

</div>

Did you ever find a better way to do this?

Thanks!

---

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [April 24, 2021, 8:24pm UTC](https://community.plotly.com/t/extending-dash-components/32088/5 "2021-04-24T20:24:29Z")

</div>

No, but I would be happy to know if a better approach :). What are you customizing?

---

<div class="post-metadata">

**Author:** ![hhoeflin](https://avatars.discourse-cdn.com/v4/letter/h/ba9def/32.png) [@hhoeflin](https://community.plotly.com/u/hhoeflin)\
**Post date:** [April 25, 2021, 5:20am UTC](https://community.plotly.com/t/extending-dash-components/32088/6 "2021-04-25T05:20:42Z")

</div>

Nothing in particular yet, I have a few ideas but was wondering how to best approach it. And am too novice with javascript to have anything better than you do 😉

---

<div class="post-metadata">

**Author:** ![rafaelqntn](https://avatars.discourse-cdn.com/v4/letter/r/bc8723/32.png) [@rafaelqntn](https://community.plotly.com/u/rafaelqntn)\
**Post date:** [June 19, 2021, 5:57am UTC](https://community.plotly.com/t/extending-dash-components/32088/7 "2021-06-19T05:57:53Z")

</div>

> [@Emil](#):
>
> Since i was not able to figure out any smart way to extend a dash component, i ended up with the follo

Hello, people.

If you are still looking for the “solution”, check [this answer.](https://community.plotly.com/t/using-a-dash-core-component-within-a-custom-component/41052/2)

The idea is to add the library to your dependencies and give an alias to the component you are extending. I put a simple example there using a `Button` from the `dash-bootstrap-components`.

Happy coding!
