pythonbackground-colorpy-shiny

How can I change the background color of an action button?


I have a Shiny for Python app with some buttons. I want to change the color of a button. How can I do this?

from shiny.express import ui

with ui.layout_columns():
    ui.input_action_button("red_button", "Make this button red!")
    ui.input_action_button("blue_button", "Make this button blue!")

Solution

  • You can pass a style attribute and set the background-color:

    from shiny.express import ui
    
    with ui.layout_columns():
        ui.input_action_button(
            "red_button", 
            "Make this button red!", 
            style = "background-color: red;"
        )
        ui.input_action_button(
            "blue_button", 
            "Make this button blue!",
            style = "background-color: lightblue;"
        )
    

    enter image description here