How To Create Dash Callbacks Without Outputs

Helped by a Nerd
3 min readFeb 26, 2023

Yes, it is possible. Dash Extensions provides functionalities to write callbacks without the necessity to add an output. In this article, I will introduce you to the NoOutputTransform.

Image by author

What Is a Callback In Dash?

Dash callbacks are implemented using the @app.callback decorator. The core structure of a dash callback consists of specifying one or more input components and their corresponding properties that trigger the callback, and one or more output components and their corresponding properties that are updated by the callback. The following minimal example shows the basic structure of a callback.

@app.callback(
Output(component_id='dummy-div', component_property='children'),
Input(component_id='dummy-button', component_property='n_clicks'),
prevent_initial_call=True
)
def update_output(n_clicks):
print("Button has been clicked")
return "Callback trigger count: {n_clicks}"

In the example above the callback consists of a single output and a single input. The output is a simple html.Div that will hold our children. In this case, it is going to display the callback trigger count. The input is a dummy button that will trigger the callback when the button is clicked. The decorated function will perform the individual logic. The prevent_intial_call is to ensure that…

--

--

Helped by a Nerd

Helped by a Nerd: Engineer who writes about automation, software engineering, and digital tools.