Callback output for tabs error


I’m using a callback to return a DIV to dash tab and it generates the following error:

dash._grouping.SchemaTypeValidationError: Schema: [<Output `tabs_mpm_content.children`>, <Output `tabs_mpm.value`>]
Path: ()
Expected type: (<class 'tuple'>, <class 'list'>)
Received value of type <class 'dash.html.Div.Div'>:

My code is:
app.layout = html.Div([
    dcc.Tabs(id="tabs_mpm", value='graph-with-slider', style={'width': '80%'}, children=[
        dcc.Tab(label='Casos Novos', value='graph-with-slider'),
        dcc.Tab(label='Baixados', value='graph-baixas'),
        dcc.Tab(label='Pendentes', value='graph-pendentes'),
        dcc.Tab(label='TC', value='graph-tc'),
        dcc.Tab(label='IAD', value='graph-iad'),
        dcc.Tab(label='Sentenças', value='graph-sent'),
        dcc.Tab(label='Decisões', value='graph-dec'),
        dcc.Tab(label='Audiências', value='graph-aud')
    html.Div(id='tabs_mpm_content', children=[
        style={'width': '80%', 'display': 'inline-block', 'vertical-align': 'middle'}

Show graph based on tab selection function:

@app.callback(Output('tabs_mpm_content', 'children'),
              Output('tabs_mpm', 'value'),
              Input('tabs_mpm', 'value'))

def render_content(tab):
    if tab == 'graph-with-slider':
        return html.Div(
    elif tab == 'graph-baixas':
        return html.Div(
    elif tab == 'graph-pendentes':
        return html.Div(
    elif tab == 'graph-tc':
        return html.Div(
    elif tab == 'graph-iad':
        return html.Div(
    elif tab == 'graph-sent':
        return html.Div(
    elif tab == 'graph-dec':
        return html.Div(
    elif tab == 'graph-aud':
        return html.Div(

I know the error message is about returning DIV instead of a list, but how should I fix it?

Hi @pedromsouza

It looks like your callback has two outputs, but you are only returning one Div

Note – You can make your code more readable by enclosing it in three back-tics:

type or paste code here
1 Like

Thanks for reply. Removing one of the outputs made it stop working… Sorry, I’m really a beginner in dash.

Due to the error message, I thought the output format caused it:

dash._grouping.SchemaTypeValidationError: Schema: [<Output tabs_mpm_content.children>, <Output tabs_mpm.value>]
Path: ()
**Expected type: (<class ‘tuple’>, <class ‘list’>)**
**Received value of type <class ‘dash.html.Div.Div’>:**

Hi @pedromsouza

I’d like to help, but it’s hard without a minimal example that reproduces the error. Learn more about how to do that here:

And please be sure to update your code in the original post so that it’s more readable :slight_smile:

1 Like


Did you remove this one?: Output('tabs_mpm', 'value'),
What error did you get?

It looks like your app is very similar to this one in the docs: Tabs | Dash for Python Documentation | Plotly

If you copy and paste that app and run it yourself locally, do you get an error?

1 Like

When I removed this output, it ran without errors, but charts inside each tab didn’t work (they are blank).

I based my app on the exemple you mentioned, but the original code (Tabs Docs) work without errors.

It’s not displaying a figure, because you only specify the id You need to add the figure prop as well.

You can see lots of simple example apps here: