Button label HTML rendering

Hi,

I would like to have a button with multiple lines of text as the label. Ideally I was hoping to pass an HTML div with all of the text and styling and line breaks that I wanted.

I started with just trying to see if the bold tag would render, but it did not

button = Button(label="<b>Foo</b>", button_type="success")
button.js_on_event("button_click", CustomJS(code="console.log('button: click!', this.toString())"))

the button documentation says “Either HTML or plain text label for the button to display”, so I was hoping the HTML would be rendered. Am I missing something?

Best,
Andy

I was able to figure it out. I needed to import the HTML class.

from bokeh.models.dom import HTML
button = Button(label=HTML("<b>Foo</b>"), button_type="success")
button.js_on_event("button_click", CustomJS(code="console.log('button: click!', this.toString())"))
2 Likes