Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Display different components based on callback output condition

$
0
0

Is it possible to return different types of components based on what a callback returns?

app.layout = dbc.Placeholder(id="fill_it")

@app.callback(
    Output(
        dict(       #<-- single Output accepts a dict of possibilities
             "1st" = dict(  #<--- identifier
                 component_id = "fill_it", 
                 component_property = content
             ),
            "2nd" = dict(
                component_id = "fill_it",
                component_property = content
            )
        )
    ),
    Input(component_id='fill_dropdown', component_property='value')
)
def filler(value):
    if (value is None):
        key = "1st"
        content = _
    elif (value is not None):
        key = "2nd"
        content = _
    return key, content

Based on the returned key, a different element from the Output dict is rendered. Something like that. Or you could have a SubOutput(key).

The reason why I ask is that it feels like there are a lot of questions out there about making adjustments based on what the data layer returns:

I am pretty sure Jinja’s Python handlebars (static front end) can do this.

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles