☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Button formatting

Community Support
paul_c
paul_c

@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

⌁   Link to post
paul_c
paul_c

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’

⌁   Link to post
nmasnadi
nmasnadi

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

⌁   Link to post

End of archived discussion · Replies are disabled