This should be straightforward, but I can’t figure out how to access what the user has typed into a html.Textarea
.
This is how I generate the component:
def text_area(id, rows=10, placeholder="..."):
area = html.Textarea(
id=id,
className="textarea",
placeholder=placeholder,
rows=rows
)
return area
I am assuming that the text is stored in the value
attribute, but that is always None
.
You’re looking for dcc.Textarea
rather than html.Textarea
https://dash.plot.ly/dash-core-components/textarea
1 Like
I just went down a rabbit hole of “I’m sure I’ve used this prop before why can’t I get a simple demo to work”
As a result if anyone ever wants to print out all available props from dash_html_component
here is some example code:
import dash
import pprint
import dash_html_components as html
app = dash.Dash(__name__)
text_area = html.Textarea(
id='test-textarea',
className="textarea",
placeholder='Type here..',
rows=10
)
app.layout = html.Div([
text_area,
html.Br(),
html.Pre(id='test-output')
])
inputs = {}
for available_property in text_area.available_properties:
if all(not available_property.startswith(a) for a in text_area.available_wildcard_properties):
inputs[available_property] = dash.dependencies.Input('test-textarea', available_property)
@app.callback(
output=dash.dependencies.Output('test-output', 'children'),
inputs=list(inputs.values())
)
def get_value_from_textarea(*args):
return pprint.pformat(dict(zip(inputs.keys(), args)))
if __name__ == '__main__':
app.run_server(debug=True, dev_tools_ui=True)
1 Like