使用 plotly/dash 更改链接的外观

Change appearance of links with plotly/dash

我正在与 Dash 合作构建仪表板。考虑以下代码:

def get_index():
    index = html.Div([
        dcc.Link('Page 1', href='/page-1'),
        html.Br(),
        dcc.Link('Page 2', href='/page-2')
    ], style = {'display':'inline-block','columnCount': 2})
    return index

这会在我的应用程序中提供以下输出:

问题:如何删除链接下方的栏并更改字体和颜色?

谢谢!

您可以通过添加 style 作为命名参数来自定义链接,例如

dcc.Link('Page 1', href='/page-1', 
         style={'font-family': 'Times New Roman, Times, serif', 'font-weight': 'bold'})

样式参数只是常规 CSS。

我认为将 external CSS 添加到您的 Dash 应用程序更可取,因为您可以分离代码逻辑和布局。