# Button (and other components) override css for hover

**URL:** <https://community.plotly.com/t/button-and-other-components-override-css-for-hover/44908>\
**Category:** Dash Python\
**Created:** [September 15, 2020, 10:00am UTC](https://community.plotly.com/t/button-and-other-components-override-css-for-hover/44908 "2020-09-15T10:00:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![luiz](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@luiz](https://community.plotly.com/u/luiz)\
**Post date:** [September 15, 2020, 10:00am UTC](https://community.plotly.com/t/button-and-other-components-override-css-for-hover/44908/1 "2020-09-15T10:00:39Z")

</div>

How can I override a Button (bootstrap component) css for when hovering?  
E.g.:  
dbc.Button(“Name”,  
style={  
‘background-color’: ‘transparent’,  
‘border-color’: ‘transparent’,  
‘color’: ‘#000000’,  
‘hover-background-color’: ‘#555555’  
}),

---

<div class="post-metadata">

**Author:** ![seferoezcan](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@seferoezcan](https://community.plotly.com/u/seferoezcan)\
**Post date:** [September 15, 2020, 12:20pm UTC](https://community.plotly.com/t/button-and-other-components-override-css-for-hover/44908/2 "2020-09-15T12:20:16Z")

</div>

You can always do it via pure CSS and assigning a className. Or since its all in React u cann ad _“:hover”:{…}_ inline into the attribute style.

---

<div class="post-metadata">

**Author:** ![luiz](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@luiz](https://community.plotly.com/u/luiz)\
**Post date:** [September 15, 2020, 1:09pm UTC](https://community.plotly.com/t/button-and-other-components-override-css-for-hover/44908/3 "2020-09-15T13:09:43Z")

</div>

Hi seferoezcan, thanks for the suggestion.

But I’d still like to know if that’s possible through the “style” keyword. For example, what if I want to change those properties after a callback?

---

<div class="post-metadata">

**Author:** ![seferoezcan](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@seferoezcan](https://community.plotly.com/u/seferoezcan)\
**Post date:** [September 15, 2020, 1:24pm UTC](https://community.plotly.com/t/button-and-other-components-override-css-for-hover/44908/4 "2020-09-15T13:24:18Z")

</div>

As i said in the second _:hover:{}_ in style should do the trick.

---

<div class="post-metadata">

**Author:** ![luiz](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@luiz](https://community.plotly.com/u/luiz)\
**Post date:** [September 15, 2020, 2:45pm UTC](https://community.plotly.com/t/button-and-other-components-override-css-for-hover/44908/5 "2020-09-15T14:45:47Z")

</div>

I tried it with:  
style={  
‘:hover’: {‘background-color’: ‘#555555’}  
}

but it didn’t work. Any other ideas?

---

<div class="post-metadata">

**Author:** ![HansPeter123](https://avatars.discourse-cdn.com/v4/letter/h/3be4f8/32.png) [@HansPeter123](https://community.plotly.com/u/HansPeter123)\
**Post date:** [September 15, 2020, 9:21pm UTC](https://community.plotly.com/t/button-and-other-components-override-css-for-hover/44908/6 "2020-09-15T21:21:42Z")

</div>

I would also recommend using an external css stylesheet to target the hover behavior. It is worth taking a look at this documentation: [https://dash.plotly.com/external-resources](https://dash.plotly.com/external-resources)  
I hope this helps

---

<div class="post-metadata">

**Author:** ![seferoezcan](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@seferoezcan](https://community.plotly.com/u/seferoezcan)\
**Post date:** [September 16, 2020, 5:47am UTC](https://community.plotly.com/t/button-and-other-components-override-css-for-hover/44908/7 "2020-09-16T05:47:44Z")

</div>

Have you tried changing it to backgroundColor? React doesnt use standard CSS/HTML keywords. Try _backgroundColor_

---

<div class="post-metadata">

**Author:** ![luiz](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@luiz](https://community.plotly.com/u/luiz)\
**Post date:** [September 16, 2020, 1:52pm UTC](https://community.plotly.com/t/button-and-other-components-override-css-for-hover/44908/8 "2020-09-16T13:52:50Z")

</div>

I tried with _backgroundColor_, both html and dbc Button classes, none worked.

I think my question is a bit more general: how is it possible to change CSS selectors such as `:hover`. `:active`, `::after` by means of the `style` keyword?

I could do most of the changes in CSS, but it half defeats my purpose here, which is keep as much logic as possible in python.  
Besides, having complete access to all CSS styling through `style` keyword would allow an easier way to distribute customized components (e.g. as pip installable) without the need for distributing the specific css file as well (and requiring that it be loaded at the app initialization)

---

<div class="post-metadata">

**Author:** ![luiz](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@luiz](https://community.plotly.com/u/luiz)\
**Post date:** [September 16, 2020, 2:00pm UTC](https://community.plotly.com/t/button-and-other-components-override-css-for-hover/44908/9 "2020-09-16T14:00:12Z")

</div>

I opened a question with the proper formulation here: [Is it possible to change CSS selectors such as :hover. :active, ::after with the `style` keyword?](https://community.plotly.com/t/is-it-possible-to-change-css-selectors-such-as-hover-active-after-with-the-style-keyword/44985)

so I’m closing this one
