DCC TextArea - Prepopulate with inpput values from other components?

Hi All,

Just wondering if this is possible? Chained callbacks can allow us to place text into the textarea, but I was wondering if it’s possible to pre-populate certain text, with gaps for population by these inputs in a similar way to string formatting?

Any minimal working examples greatly appreciated.

Thanks in advance.

Your question is a bit unclear. Is this what you mean?

import dash
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output

template = "Hello {}"
initial_value = "world"

app = dash.Dash()
app.layout = html.Div([
    dcc.Input(value=initial_value, id="text_input", style=dict(width="100%")),
    dcc.Textarea(value=template.format("world"), contentEditable=False, id="text_area", style=dict(width="100%"))
])

@app.callback(Output("text_area", "value"), Input("text_input", "value"))
def update(value):
    return template.format(value)

if __name__ == "__main__":
    app.run_server()
1 Like