Good day, I am a dash beginner.
I have a sidebar with a dropdown component which is multiselect.
The dropdown contains plots that when selected will be plotted.
When you keep adding plots, it will keep expanding the sidebar.
My code:
# styling the sidebar
SIDEBAR_STYLE = {
"position": "fixed",
"top": 0,
"left": 0,
"bottom": 0,
"padding": "2rem 1rem",
"background-color": "#f8f9fa",
# 'width': '100%'
}
sidebar = html.Div(
[
html.H2("Well App", className="display-4"),
html.Hr(),
html.P(
"Well App is for plotting of different well data", className='lead'
),
html.Div(
[
dbc.Label("Select Unit"),
dbc.RadioItems(
id="unit",
options=[{"label": i, "value": i} for i in unit_lst],
value=unit_lst[0],
inline=True,
),
],
className='mb-3'
),
html.Div(
[
dbc.Label(id='unit-selctd', children=[]),
dcc.Dropdown(id='unit-selctd-dpdn', multi=False,
value='Field', options=[], className='mb-2',
style={'width': '100% !important'}),
]
),
html.Div(
[
html.Label('Plots'),
dcc.Dropdown(id='figs-to-plot', multi=True,
value='Field', options=[]),
]
),
],
style=SIDEBAR_STYLE
className=''
)
tab_container = html.Div(id='tab-content')
app.layout = dbc.Container([
dbc.Row([
dbc.Col(sidebar, width=4),
dbc.Col(tab_container)
])
], fluid=True)
I saw this solution in stack-over: flow javascript - Stop dropdown width from expanding - Stack Overflow which suggests that I use
#auswahl{
width:50%;
}
I have problem with the solution
The dropdown is in a sidebar and I styled the sidebar width using bootstrap by asking it to take 4 of the whole width and I want the dropdown to take up the sidebar width as it is the parent, so when I made dropdown width to be 100%, it made the sidebar to take up the whole width of the screen which is not what I want.
Please tell me how to solve this and if possible include the code for me please.
Thank you