# Programmatically create a React component from Python

**URL:** <https://discuss.streamlit.io/t/programmatically-create-a-react-component-from-python/18032>\
**Category:** Custom Components\
**Created:** [October 12, 2021, 5:31pm UTC](https://discuss.streamlit.io/t/programmatically-create-a-react-component-from-python/18032 "2021-10-12T17:31:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![solarjoe](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/solarjoe/32/5698_2.png) [@solarjoe](https://discuss.streamlit.io/u/solarjoe)\
**Post date:** [October 12, 2021, 5:31pm UTC](https://discuss.streamlit.io/t/programmatically-create-a-react-component-from-python/18032/1 "2021-10-12T17:31:19Z")

</div>

Hello,

I have a question and hope that you have some ideas on this.

Say you want to shift was much coding as possible towards the Python part of  
Streamlit and do as little as possible on the JavaScript, React side of a Custom Component.

I am thinking about if it would be possible to have something like a generic custom component  
that could morph into any React component just by the parameters you are injecting  
from the Python side. But I am not sure if this is feasible at all.

Something like

```auto
import generic_custom_component

attr = {}
attr["autoComplete"] = True
attr["style"] = 'some css here'
attr["disabled"]="{this.props.disabled}"
attr["onChange"] = "some code here"
attr["render_func"] = """
      <span>
        Hello, {name}! &nbsp;
        <button
          style={style}
          onClick={this.onClicked}
          disabled={this.props.disabled}
          onFocus={this._onFocus}
          onBlur={this._onBlur}
        >
          Click Me!
        </button>
      </span>
"""

result = generic_custom_component(type="TextInput",
                                  name="Streamlit",
                                  attr=attr)

```

What are your thoughts about this?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [October 12, 2022, 5:31pm UTC](https://discuss.streamlit.io/t/programmatically-create-a-react-component-from-python/18032/2 "2022-10-12T17:31:37Z")

</div>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
