Toggle between dark/light-mode

I have a static html, and I’d like to add a button to toggle between light and dark modes, as it’s done here:

I have tried to select all the .js-plotly-plot or the .plotly-graph-div and activate the different classes on them, but that didn’t work.

Is there a (relatively simple) way to do this, without having to redefine and relayout the whole graph?

Thanks in advance!