Formatting and color the text

Hi @liuzc123

If you change the callback to something like this it should work:

@app.callback(
    Output(component_id="output_children", component_property="children"),
    Input(component_id="button", component_property="n_clicks"),
    State(component_id="textarea", component_property="value"),
    prevent_initial_call=True,
)
def update_output(n_clicks, textarea):
    if n_clicks > 0:
        return html.H1(
            [
                html.Span("You have entered: ", style={"color": "blue"}),
                html.Span(textarea, style={"color": "red"}),
            ]
        )

2 Likes