Comments (4)
@arnaudmiribel It should work if you add these styles in separate entries in a list, e.g.:
import streamlit as st
from streamlit_extras.stylable_container import stylable_container
with stylable_container(
key="comic_sans_button",
css_styles=["""
button {
background-color: green;
color: white;
border-radius: 5px;
}
""",
"""
button > div > p {
font-family: "Comic Sans MS", "Comic Sans", cursive;
}
"""
],
):
st.button("Comic Sans button")
st.button("Other button")
btw. nice usage of the playground :)
from streamlit-extras.
Hey @iuiu34,
It is! But you need to adjust the CSS path accordingly. Instead of pointing on the button itself, you need to go and point on the button's text, which is a few elements below (namely > div > p
). Here's the updated code:
import streamlit as st
from streamlit_extras.stylable_container import stylable_container
with stylable_container(
key="comic_sans_button",
css_styles="""
button {
background-color: green;
color: white;
border-radius: 5px;
}
button > div > p {
font-family: "Comic Sans MS", "Comic Sans", cursive;
}
""",
):
st.button("Comic Sans button")
from streamlit-extras.
Btw @LukasMasuch is there a cleaner way to do this? I figured if I now added buttons before/after, while they wouldn't get the background applied, they would still use the font family. Is there a way for the font family to be only applied to the container?
from streamlit-extras.
Oh yea my bad, even better!
from streamlit-extras.
Related Issues (20)
- error running app HOT 1
- 🐛 [BUG] - `st.experimental_memo is deprecated` error on streamlit-extras home page HOT 1
- Patch requests for stlite playgrounds which require GET calls
- ✨ [IDEA] - Allow manual `key` for `dataframe_explorer` HOT 1
- 🐛 [BUG] - Metric Cards Show as default Streamlit Metric with Streamlit 1.28.0 HOT 3
- 🐛 [BUG] - <title> stylable_container [streamlit-extras-0.3.4] do not support streamlit=1.28.1
- ✨ [IDEA] - Adding support for query parameters in switch_page HOT 3
- 🐛 [BUG] - Streamlit 1.29.0 breaks row vertical align options HOT 1
- Mark the no-default selectbox, Stateful Chat, styleable container, metric cards as (partially) solved natively,
- Edit add_logo module with also text for multipages app HOT 1
- ✨ [IDEA] - Stateful chat support for expanders, buttons, etc. HOT 2
- Tags extra - custom color HOT 1
- "add_vertical_space" is not accessed HOT 1
- st.experimental_rerun() will e removed soon and is used in stateful_button
- 🐛 [BUG] - Hardcoded main script path in switch_page_button extra HOT 2
- New release on PyPI? HOT 6
- style_metric_cards bug on dark mode HOT 1
- 🐛 [when using bottom container the app scrolls automatic to the bottom of the page] - Bottom container scrolling issue
- 🐛 [BUG] - add_logo not working with st_pages package HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from streamlit-extras.