Dash Bootstrap Cheat Sheet
Dash Bootstrap Cheat Sheet
Dash Bootstrap combines the power of Dash and Bootstrap, allowing you to easily style your Dash apps with familiar Bootstrap classes. Here’s a cheatsheet to get you started:
Concepts:
Grid System:
- Divide your layout into rows and columns with dbc.Row and dbc.Col components.
- Specify column widths using Bootstrap grid classes like col-md-6 (6 columns on medium screens).
- Example:
1 2 3 4
dbc.Row([ dbc.Col("Column 1", width=4), dbc.Col("Column 2", width=8), ])
Utility Classes:
- Apply various styles using Bootstrap utility classes like text-center, mt-3 (margin top 3), border-primary.
- Example:
1
dbc.Button("Click Me", className="btn btn-primary mt-3")
- Colors:
- Use Bootstrap color classes like text-primary, bg-success, border-warning. Example:
1 2 3 4
dbc.Card( [dbc.CardBody("This card has a success background")], className="bg-success text-white", )
- Typography:
- Control font size, weight, and style with Bootstrap typography classes like h1, lead, text-muted.
- Example:
1
dbc.Heading("This is a heading", className="h2 text-center")
- Other Components:
Style other Bootstrap components like buttons, cards, alerts, etc. using their respective classes. Tips:
- Explore the official Bootstrap documentation for more styling options: https://getbootstrap.com/docs/5.2/getting-started/introduction/
- Refer to the Dash Bootstrap Theme Explorer for examples: https://dash-bootstrap-components.opensource.faculty.ai/docs/themes/explorer/
- Use online tools like the Dash Bootstrap Cheatsheet: https://dashcheatsheet.pythonanywhere.com/ for interactive exploration.
Additional Resources:
Dash Bootstrap Components Documentation: https://dash-bootstrap-components.opensource.faculty.ai/ AnnMarieW’s Dash Bootstrap Cheatsheet: https://github.com/AnnMarieW/dash-bootstrap-cheatsheet How to Style your Dash App with Bootstrap Cheat Sheet (YouTube): https://www.youtube.com/watch?v=VTO6Njy10dY Remember, this is just a starting point. Experiment with different classes and explore the vast possibilities of Dash Bootstrap styling to create beautiful and user-friendly dashboards!