Plotly Dash 主题:LUX(深色模式)

问题描述 投票:0回答:1

我想使用内置的 Bootswatch 主题 LUX,但看起来 Dash 中只包含轻量模式,即当我使用下面的示例代码时,主题会在轻量模式下应用。我怎样才能拥有深色模式呢?我不太关心在浅色和深色模式之间切换的能力,只想在深色模式下使用这个主题作为默认和唯一的选项。谢谢你的帮助。

import dash
import dash_bootstrap_components as dbc
app = dash.Dash(external_stylesheets=[dbc.themes.LUX])
python plotly plotly-dash
1个回答
0
投票

找到了,只需要在assets中保存一个.js文件即可:

document.documentElement.setAttribute('data-bs-theme', 'dark')

来源:https://hellodash.pythonanywhere.com/adding-themes/color-modes

© www.soinside.com 2019 - 2024. All rights reserved.