Tabulator Font Size

How does one change font size of text in a Tabulator widget? I’d prefer to change an attribute rather than defining CSS stuff (that I’m not familiar with at this time).

A conversational AI tool gave me this nice example, but it doesn’t actually change the font size:

import panel as pn
import pandas as pd

# Create a sample DataFrame
data = {'Name': ['John', 'Jane', 'Mike'],
        'Age': [25, 30, 35]}
df = pd.DataFrame(data)

# Create a Panel Tabulator object
table = pn.widgets.Tabulator(df)

# Set the font size for the table cells
table.style_cell = {'font-size': '16px'}  # Change the font size to your desired value

# Display the table
table.show()

In the end, I’m really trying to create a much more-compact table of information (think Excel-style). Any suggestions, besides changing font size, would be welcome. The best I’ve done so far is to use theme='bootstrap5', theme_classes=['table-sm'].

I don’t think there is a way to do this, and even if we have exposed it, you will find some other attribute that you can’t control with an attribute. Here is an example with CSS, even though this is explicitly what you asked not to have.

import panel as pn
import pandas as pd

pn.extension('tabulator')

# Create a sample DataFrame
data = {'Name': ['John', 'Jane', 'Mike'],
        'Age': [25, 30, 35]}
df = pd.DataFrame(data)

# Create a Panel Tabulator object
stylesheet = """
.tabulator-cell {
    font-size: 16px;
}
"""

table = pn.widgets.Tabulator(df, stylesheets=[stylesheet])

# Display the table
table

@Hoxbro Thanks, that wasn’t too bad.