简体   繁体   中英

Plotly change font and background color when hovering dropdown button

Is there a way to add custom CSS to Plotly dropdown buttons? I have the following ones:

...
updatemenus=[
  dict(buttons=[
    dict(
      args=["type", "bar"],
      label="Bar Chart",
      method="restyle",
    ),
    dict(
      args=["type", "scatter"],
      label="Line Chart",
      method="restyle",
    )
  ]
  , direction="down"),
...

But when using a figure with the theme plotly_dark , this is how they look like when hovering : 在此处输入图像描述

I saw properties bgcolor, bordercolor, borderwidth... but nothing regarding hover styling. Anyone was able to make it work?

Thank you

You should use

font = dict(color='#000000')

For example,

...
updatemenus=[
  dict(buttons=[
    dict(
      args=["type", "bar"],
      label="Bar Chart",
      method="restyle",
    ),
    dict(
      args=["type", "scatter"],
      label="Line Chart",
      method="restyle",
      )
    ],
  direction="down",
  font = dict(color='#000000'),
  ),
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM