Hi, I am very new in Dash.
I am trying to create a Tabed dash board . In which each tab contain a button and each button perform different functionality.
What I did: I created tab and in each tab i created buttons and on button click i try to use @callback but its not working can any one suggest how to solve the issue
hear is my code
import dash_bootstrap_components as dbc
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output, State
app = dash.Dash(external_stylesheets=[dbc.themes.CYBORG])
tab1_content = dbc.Card(
dbc.CardBody(
[
dbc.Button("tab_1btn", color="success",id="tab1"),
]
),
className="mt-3",
)
tab2_content = dbc.Card(
dbc.CardBody(
[
dbc.Button("tab2_btn", color="danger",id="tab2"),
]
),
className="mt-3",
)
content = html.Div(children =
[
dbc.Tabs(
[
dbc.Tab(tab1_content, label=âHomeâ,tab_id = âHomeâ),
dbc.Tab(tab2_content, label=âSnowflakeâ,tab_id = âSnowflakeâ),
], id = âtabâ,
),
html.Div(id=âouttbllistâ),
]
)
app.layout = html.Div([dcc.Location(id=âurlâ), content])
@app.callback(Output(âouttbllistâ, âchildrenâ),
Input(âtab1â, ân_clicksâ),
Input(âtabâ, âvalueâ),
prevent_initial_call=True )
def data_profilingview(n_clicks,active_tab):
if active_tab == âscatterâ:
return html.P(âThis is tab 1!â, className=âcard-textâ)
@app.callback(Output(âouttbllistâ, âchildrenâ),
Input(âtab2â, ân_clicksâ),
prevent_initial_call=True )
def data_profilingview(n_clicks):
return html.P(âThis is tab 2!â, className=âcard-textâ)
if name == âmainâ:
app.run_server(port=8080)