Skip to content

Instantly share code, notes, and snippets.

@AnnMarieW
Created August 22, 2022 15:02
Show Gist options
  • Save AnnMarieW/5658f05627f3122690a5750e304c3b6f to your computer and use it in GitHub Desktop.
Save AnnMarieW/5658f05627f3122690a5750e304c3b6f to your computer and use it in GitHub Desktop.
Center a card in a row with Dash Bootstrap Components
from dash import Dash, html
import dash_bootstrap_components as dbc
app = Dash(
__name__,
external_stylesheets=[dbc.themes.BOOTSTRAP],
)
card = dbc.Card(
dbc.CardBody(
[
html.H4(html.B("card title"), className="card-title"),
html.Hr(),
html.H2(
html.B("card text"),
className="card-text",
),
]
),
style={
"width": "18rem",
"border-radius": "2%",
},
)
app.layout = dbc.Container(
[
dbc.Row(dbc.Col("Dashboard", className="text-center mt-4 mb-5 h1 fw-bold")),
dbc.Row(
[
dbc.Col(card, width="auto"),
dbc.Col(card, width="auto"),
],
justify="center",
),
],
fluid=True,
)
if __name__ == "__main__":
app.run_server(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment