So here’s a minimum example of my code and I’m not sure why the col components that I’m adding in a pattern matching callback aren’t working as I would expect? They’re not the right size and they’re not filling in the parent container? Any help would be much appreciated. The goal is for the items of the pattern matching callback to responsively fill in the space, which equates to setting them to size 6 width on xs + sm displays and 12 width on md displays and upwards. Thanks!
from dash import html, dcc, Input, Output, State, Dash
import dash_bootstrap_components as dbc
style = dbc.themes.BOOTSTRAP
app = Dash(__name__, external_stylesheets=[style])
# Placeholder application layout
app.layout = dbc.Container([
dbc.Row(
[
dbc.Col(
[
dbc.Button(
"Placeholder Button", className="", id="button", n_clicks=0,
),
dbc.Row(html.Div(id="test_id", children=[])),
],
width=6
),
],
),
], fluid=True,)
@app.callback(
Output("test_id", "children"),
Input("button", "n_clicks"),
State("test_id", "children"),
prevent_initial_call=True,
# State("cov_factors_store", "data"),
)
def display_dropdowns(n_clicks, container):
# Should just have a callback that deals with the store component, and then everything else follows from that.
new_dropdown = dbc.Col(
dcc.Dropdown(
options=[
{"label": "NYC", "value": "New York City"},
{"label": "MTL", "value": "Montreal"},
{"label": "SF", "value": "San Francisco"},
{"label": "LA", "value": "Los Angeles"},
{"label": "TOKYO", "value": "Tokyo"},
],
id={"type": "factor_dropdown", "index": n_clicks},
),
className="mb-2 px-0",
xs=6,
md=12,
)
container.append(new_dropdown)
return container
if __name__ == "__main__":
app.run_server(debug=True)