Post

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:

  1. 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),
      ])
      
  2. 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")
    
  1. 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",
    )
    
  1. Typography:

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!

This post is licensed under CC BY 4.0 by the author.