Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to make same width of various menus?

I have datePickerRange(), Input() and Dropdown(), their width are different, like showing below(white area). Thank you so much for your help

dcc.DatePickerRange(id='date-range',
                   min_date_allowed=datetime(2020,1,1),
                   max_date_allowed=datetime.today(),
                   start_date=datetime(2021,10,30), 
                   end_date=datetime(2021,11,2),
                   style = {
                        'font-size': '3px','display': 'inline-block', 'border-radius' : '2px', 
                        'border' : '1px solid #ccc', 'color': '#333', 
                        'border-spacing' : '0', 'border-collapse' :'separate'
                        } 
                    )
]
),

dbc.Label('DTS Heatmap Start Time:'),
dcc.Input(id="starttime", type="text", value='00:00',placeholder='22:00'),
dbc.Label('DTS Heatmap End Time:'),
dcc.Input(id="endtime", type="text",  value='00:00',placeholder='18:00'),

dbc.Label('DTS Data Frequency'),
dcc.Dropdown(id='data-frequency-dropdown',
         options=[
                 {'label':'Minutes','value':'Minutes'},
                 {'label':'Daily','value':'Daily'},
                 {'label':'Weekly','value':'Weekly'},
                 {'label':'Monthly','value':'Monthly'},
                 ],
         value='Minutes',                         
        ),

How to make their width the same? Thanks

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

To set the same width for both components, you can add CSS styling using the width attribute. So if you want to set an explicit width for both components, you can do something like:

dcc.DatePickerRange(id='date-range',
    min_date_allowed=dt(2020,1,1),
    max_date_allowed=dt.today(),
    start_date=dt(2021,10,30), 
    end_date=dt(2021,11,2),
    style = {
        'font-size': '3px','display': 'inline-block', 'border-radius' : '2px', 
        'border' : '1px solid #ccc', 'color': '#333', 
        'border-spacing' : '0', 'border-collapse' :'separate',
        # New CSS styling for width
        'width':'500px'
        } 
)

dcc.Input(
    id="starttime",
    type="text",
    value='00:00',
    placeholder='22:00',
    # New CSS styling for width
    style={'width':'500px'}
)

Please note that if you give the DatePickerRange component a width larger than what it needs to display the date ranges, then it’ll show some extra padding that may seem undesirable. If you want to give the input the exact width that the DatePickerRange has by default, then give it "width":"288px" , as this is approximately the default width DatePickerRange has.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading