Hi:
I am creating a set of control to let users pick a preset dates range, such as a week, two weeks, a month, and a year, or a custom set date range. I am using a dropdown menu and the date range picker to achieve this. However, I ran into the following problems:
- the font on the dropdown is bolded. I want it to be unbolded;
- the font family and transparency don’t match the date range picker;
- the font in the dropdown is not aligning vertically in the center;
- reduce the gap between the dropdown and the date range picker
Additionally, I want to adjust the three controls as a group to be all the way to the right edge of the banner, but I am having trouble getting it there.
Here is the code I am using:
import dash
import dash_bootstrap_components as dbc
from dash import dcc, html
from dash.dependencies import Input, Output, State
from datetime import datetime as dt
app = dash.Dash(
__name__,
external_stylesheets=[
dbc.themes.MINTY,
],
)
banner = dbc.Row(
[
dbc.Col(
html.H1(
"Dashboard",
className="my-3",
style={"margin-left": "10px"},
),
width = 9
),
dbc.Col(
html.Div(
dcc.Dropdown(
id="preset-day-selection",
options=[
{'label': '7 days', 'value': 'button-1'},
{'label': '14 days', 'value': 'button-2'},
{'label': '1 month', 'value': 'button-3'},
{'label': '1 school year', 'value': 'button-4'},
],
value='button-4',
clearable=False,
style={
'fontSize': '1.1em',
'height': '48px',
},
),
style={
"font-weight":"normal",
"width":"100%",
"align-items":"center",
"text-align":"center",
"font-family":"sans-serif",
"font-color":"grey",
"font-size":"1.1em"
}
),
width = 1,
style={
"display": "flex",
"align-items":"center",
"justify-content": "flex-end",
}
),
dbc.Col(
[
dcc.DatePickerRange(
id="date-picker",
start_date_placeholder_text="Start Date",
end_date_placeholder_text="End Date",
calendar_orientation="horizontal",
min_date_allowed=dt(2014, 8, 1),
initial_visible_month=dt(2022, 1, 1),
start_date=dt(2020, 8, 3),
style={
"background-color": "#FFA500",
"margin-left": "5px",
"display": "flex",
"flex-direction": "row",
},
className="me-1"
),
dbc.Button("Search", id="apply-button", color="primary", class_name="me-1 btn-pill"),
],
width = 2,
style={
"display": "flex",
"align-items": "center",
"justify-content": "flex-start",
"background-color": "#FFA500",
},
className="g-0"
),
],
className="my-3",
style={"background-color": "#FFA500", "color": "black"},
)
app.layout = dbc.Container(
[
banner,
],
fluid=True,
className="p-5"
)
if __name__ == "__main__":
app.run_server(host="10.1.1.1", port=8023, debug=True)
Here is the result I am getting:
Thank you in advance for your help.
Mike