dash-bootstrap-components-徽章

from logging import debug
import dash
from dash import Input, Output, State, html
import dash_bootstrap_components as dbc
from dash_bootstrap_components.themes import BOOTSTRAP

app = dash.Dash(external_stylesheets=[dbc.themes, BOOTSTRAP])

badge = html.Div(
    [
        # 徽章外面可以加按钮
        dbc.Button(
            [
                "通知",
                # 设置徽章属性
                dbc.Badge("4", color="light", text_color="primary", className="ms-1"),
            ],
            color="primary",
        ),
        html.Div(
            [
                # 默认文本颜色 白色
                dbc.Badge(
                    "Primary",
                    color="primary",
                    # 可以加入链接,默认会有下划线,清除掉text-decoration-none
                    href="#",
                    className="me-1 text-decoration-none",
                ),
                dbc.Badge(
                    "Secondary,圆润一些",
                    color="secondary",
                    pill=True,
                    className="me-1 ",
                ),
                dbc.Badge(
                    "Success",
                    color="success",
                    # pill=True让徽章圆润一些
                    pill=True,
                    className="me-1",
                    href="#",
                ),
                dbc.Badge("Warning", color="warning", className="me-1"),
                dbc.Badge("Danger", color="danger", className="me-1"),
                dbc.Badge("Info", color="info", className="me-1"),
                # text_colo设置文本颜色
                dbc.Badge("Light", color="light", text_color="dark", className="me-1"),
                dbc.Badge("Dark", color="dark", className="me-1"),
                dbc.Button(
                    [
                        "通知",
                        # 设置徽章定位在按钮的某一个位置
                        dbc.Badge(
                            "99+",
                            color="danger",
                            pill=True,
                            text_color="white",
                            className="position-absolute top-0 start-100 translate-middle ",
                        ),
                    ],
                    color="primary",
                    className="position-relative",
                ),
            ]
        ),
    ]
)


app.layout = dbc.Container(badge, fluid=True)
if __name__ == "__main__":
    app.run_server(debug=True)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值