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)