I use unsafe_allow_html small hack to load custom CSS and change text color, background color and button radius. I think custom CSS is being internally discussed so we can expect some new things soon
For horizontal layout of those widgets, there’s an issue for this, I’ll link your use case to it.
That magnifying glass in the Streamlit button…I have no idea yet how to inject material-icon or a png in the button legend, if you’re interested in that you may write an issue on Github
When you say “search field”, do you want autocompletion too for your text_input ? The API could look like st.text_input(“Search”, autocomplete=function())…that could also be interesting
@Charly_Wargnier did you manage do make it work ? Still works on my side, make sure your app.py and styles.css are in the same folder.
Sooo…it’s getting tricky, you can go in the Inspector tab of your web browser, find the element you want to style, copy its CSS path it in the stylesheet and then edit the colors in the stylesheet :
import streamlit as st
def local_css(file_name):
with open(file_name) as f:
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
local_css("style.css")
button_clicked = st.button("OK")
button_clicked = st.button("KO")
button_clicked = st.button("ignore")
this is not a very viable long term solution though…
we are currently experimenting with Custom Components which will enable you to create your own components into Streamlit, that means you should be able to style your own button (and maybe a search box with auto suggestion too) and change it’s color when desired from Python (if we correctly define the HTML/CSS part). I’ll keep this use case in mind and see if I can make you one when it’s out
hi thanks for sharing,
however i cant get it works , it thorw an error that StreamlitAPIException : set_page_config() can only be called once per app, and must be called as the first Streamlit command in your script.
Considering you are having an app.py file for your streamlit app code
import streamlit as st
def main():
"""
Heart of the streamlit App
"""
# Some Basic Configuration for StreamLit
st.set_page_config(
page_title="Your Awesome App Title",
page_icon="path_of_your_favicon",
layout="wide",
initial_sidebar_state="auto",
)
pages = ["Home", "Page 1", "Page 2"]
p_choice = st.sidebar_selectbox("Menu", pages)
if p_choice == "Home":
local_css("style_1.css") # Relative path of the css file
st.title("Some Relevant Info")
.
.
.
else if p_choice == "Page 2":
local_css("style_2.css")
st.title("Title of Page 2")
.
.
.
def local_css(file_name):
with open(file_name) as f:
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
if __name__ == "__main__":
main()
Either store the style_1.css, style_2.css, etc css files in the same directory as the app.py or give the relative path if you prefer something like assets\css\style_1.css
Hi everybody,
I have managed to change the default parameters of text input.
Yet, I was wandering which is the class ‘responsible’ for text input that would allow for a typewriter effect inside the text input element. .
Inspecting the code, I can notice
, which contains a number of classes.
Inside, there is the “< input >” tag?
So the final question will be:
Which is the best, “< div>” or “< input >” to insert the typewriter effect.
How to add a new class for the animation, in addition to the various st-4 st-b7 and so on.