Show/hide radio and form elements in a menu


This sort of thing is way out of my area. My app has about 20 radio buttons, dropdown boxes, checkboxes, etc. The actual figure is now beneath the fold, difficult to see without scrolling. Eventually, there will be at least 40 buttons/options which is clearly a UX nightmare but the application needs this fine level of control.

I’m trying to find a neat (react?) solution which hides the div containing all the form elements (radio buttons etc) on click, in an elegant menu. Then another click swipes them back again. Any ideas? I imagine this may come up again…




You’ll have to post some screenshots when you’re done :slight_smile:

Would something like this work?

app.layout = html.Div([
        options=[{'label': i, 'value': i} for i in ['Show', 'Hide']],
    html.Div(id='controls-container', children=[
        # all of your controls
        # ...

@app.callback(Output('controls-container', 'style'), [Input('toggle', 'value')])
def toggle_container(toggle_value):
    if toggle_value == 'Show':
        return {'display': 'none'}
        return {'display': 'block'}


Oh, simple idea. Ha, thanks Chris. Was expecting it to be way more complicated. Will see if I can expand on that - thanks a lot!


Another way to do this is to use dash_html_components.Details and dash_html_components.Summary. This is native in HTML5, no callbacks required! See for details.

    html.Summary('Label of the item'),

I use this in the dash user guide to hide/show the code blocks

Collapsible Div in Dash?

Love it @chriddyp - perfect!