New Component: Streamlined Bidirectional Component

I wanted to use bidirectional components the same way the simple html component is used. We have the following:

import streamlit.components.v1 as components

components.html("html here")

With bidirectional components, you have to set up multiple directories, index.html, maybe a frontend framework like React, etc.

streamlined_custom_component now takes care of that for you, allowing for bidirectional html/css/javascript components in a similar way to components.html above.

Here is the simple usage:

from streamlined_custom_component import create_component

input_id = 'test'
html_input = f"""
<input id="{input_id}" value="test" />
<button id="submit-button">Submit</button>
"""
java_script_input = """ 
console.log('Additional JavaScript');
"""
css_input = """
body { 
    background-color: lightblue; 
    }
"""

modifications = {
    "input_id": input_id,
    "html": html_input,
    "javascript": java_script_input,
    "css": css_input
}
my_component = create_component(component_name="custom_component1", modifications=modifications)
value = my_component()
st.write(f"Component returned: {value}")

# Display the value
print(value)

Which gives you:
streamlit_cc_readme

You can install it via:

pip install streamlined_custom_component

Github repo: Link
Pypi: Link

4 Likes

Thank you, @Juice :pray:
This is REALLY helpful article
All of these are valuable articles that give me new ideas and help us all to help each other.
Also, I would appreciate it if you could take a look at the article I posted.

New mono300genuine/streamlit-tutorial-for-education Streamlit App

Thank you for the great article, @Juice