Nirjhor Chakraborty
Nirjhor Chakraborty

Reputation: 125

How to resize Tab name area in Pyviz Panel

I'm trying to create a tab layout using Pyviz-Panel (example code below) in a Jupyter notebook. I'd like to keep the size of individual tab names the same.
However, tab.width changes/sets the size of the overall window for the Tabs set.

Even tab[0].width sets window width for the contents within tab 'A' i.e., the width of the column/button in my example below. That's not what I'm after.

How do I change the width of the name area for each tab?

import panel as pn
pn.extension()
import panel.widgets as pnw

name_list = ['A','BBB','CCCCC']
tab_contents = name_list
buttons = [pnw.Button(name="Do "+name) for name in tab_contents]
columns = [pn.layout.Column() for i in range(len(name_list))]

tab = pn.layout.Tabs()
for i in range(len(name_list)):
    columns[i].extend([buttons[i]])
    tab.append((name_list[i],columns[i]))

tab

Upvotes: 1

Views: 549

Answers (1)

lattice
lattice

Reputation: 31

Use this:

raw_css = """
.bk-root .bk-tabs-header.bk-above .bk-headers, .bk-root .bk-tabs-header.bk-below .bk-headers{
font-size:20px;
}
"""

pn.extension(raw_css=[raw_css])

You can adjust the font-size to get the desired size of the name area of tabs.

Caveat:

KaTeX stops working if the above is used. Hence, use mathjax to render any equations.

Upvotes: 0

Related Questions