Giter Club home page Giter Club logo

Comments (4)

LukasMasuch avatar LukasMasuch commented on June 2, 2024 1

@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")
image

btw. nice usage of the playground :)

from streamlit-extras.

arnaudmiribel avatar arnaudmiribel commented on June 2, 2024

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")

Demo:
image

from streamlit-extras.

arnaudmiribel avatar arnaudmiribel commented on June 2, 2024

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?

image

from streamlit-extras.

arnaudmiribel avatar arnaudmiribel commented on June 2, 2024

Oh yea my bad, even better!

from streamlit-extras.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.