Button formatting

@Alex_Kolby @mateusz

This seems to add formatting around the button, but not to the button itself. How do I change the colour of the button?

Thanks
Screenshot 2024-04-15 at 7.38.19 AM

Please provide an actual complete Minimal Reproducible Example of the code you are trying that is not working how you expect.

the screenshot is produced by the code provided in the answer by @mateusz that I referenced.

from bokeh.layouts import layout
from bokeh.io import show
from bokeh.models import Button, InlineStyleSheet

style = InlineStyleSheet(css="""
:host(.custom_button_1) {
    background-color: lightblue;
    font-weight: bold;
    color:navy;
    border-style:solid;
    border-width: 10px;
    border-color:navy;
}
""")

button = Button(label = 'hello', stylesheets = [style], css_classes = ['custom_button_1'])

main = layout(button)
show(main)

I was asking how to format the white box around ‘hello’

I don’t know much about how CSS works, but using .bk-btn seems to fix it:

from bokeh.layouts import layout
from bokeh.io import show
from bokeh.models import Button, InlineStyleSheet

style = InlineStyleSheet(css="""
.bk-btn {
    background-color: lightblue;
    font-weight: bold;
    color:navy;
    border-style:solid;
    border-width: 10px;
    border-color:navy;
}
""")

button = Button(label = 'hello', stylesheets = [style])

main = layout(button)
show(main)

Screen Shot 2024-04-16 at 10.24.43 AM

2 Likes

@mateusz is it a regression or an intended change that the css_classes approach does not seem to work as it did earlier?