Hi, I’m trying to ’ arrange html
and components
inline but Dropdown components be shrunk when cleared. Below is my sample code:
import plotly.express as px
import dash
import dash_html_components as html
import dash_core_components as dcc
import dash_bootstrap_components as dbc
app = dash.Dash(__name__,external_stylesheets=[dbc.themes.LUX])
app.layout = html.Div([
dbc.Row([
dbc.Col([
html.H6('Template', style={'text-align': 'left'}),
dcc.Dropdown(id='template',
placeholder="Please select template",
options=[{'label': 'ggplot2', 'value': 'ggplot2'},
{'label': 'plotly_white', 'value': 'plotly_white'}],
value='ggplot2',
multi=True,
disabled=False,
clearable=True,
searchable=True)
], width={'size': 12, "offset": 0, 'order': 1},className="hstack gap-3"),
], className='p-2 align-items-center'),
])
if __name__ == "__main__":
app.run_server(debug=False)
I’m using className="hstack gap-3"
to make a gap between html.H6
and dcc.Dropdown
and below is the result:
And when clearing options, it will be shown as below:
So I want to ask is there anyway (which className should I use) to arrange html
and components
inline but width of dropdown (columns) not be changed?
Actually I can use below code to arrange html
and components
inline but I don’t want to add so much Columns:
app = dash.Dash(__name__,external_stylesheets=[dbc.themes.LUX])
app.layout = html.Div([
dbc.Row([
dbc.Col([
html.H6('Template', style={'text-align': 'left'})
], width={'size': 1, "offset": 0, 'order': 1}),
dbc.Col([
dcc.Dropdown(id='template',
placeholder="Please select template",
options=[{'label': 'ggplot2', 'value': 'ggplot2'},
{'label': 'plotly_white', 'value': 'plotly_white'}],
value='ggplot2',
multi=True,
disabled=False,
clearable=True,
searchable=True)
], width={'size': 11, "offset": 0, 'order': 1}),
], className='p-2 align-items-center'),
])
if __name__ == "__main__":
app.run_server(debug=False)
Thank you.