CSS styles misalign with frozen_columns in Panel’s Tabulator

ALL software version info

(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc should be added within the dropdown below.)

Software Version Info
Panel Version: 1.7.0
Python Version: 3.10.17
OS: Linux (AWS)
Browser: Firefox 138.0.3 (aarch64)
Pandas: 2.2.3

Description of expected behavior and the observed behavior

Expected Behavior

  • Styles (e.g. font color, background color) should align with the correct cells.
  • Freezing a column should not impact visual styling alignment.

Actual Behavior

  • With frozen_columns=[0], all cell styles are offset one column to the right.
  • Without frozen columns, styles apply correctly.
  • styled_fz.style and styled.style objects appear identical and correct.
  • Applying .style.background_gradient (which uses matplotlib) does align correctly as following issue #6675, which was fixed with #7792 — maybe bug is limited to custom styling with style.map and style.apply.

Complete, minimal, self-contained example code that reproduces the issue

  • Reproducible in both Jupyter notebooks and when serving via panel serve.
import numpy as np
import pandas as pd
import panel as pn

pn.extension('tabulator')

# Seed and sample data
np.random.seed(42)
style_df = pd.DataFrame(np.random.randn(4, 5), columns=list('ABCDE'))

# Styling functions
def color_negative_red(val):
    return 'color: red' if val < 0 else 'color: black'

def highlight_max(s):
    is_max = s == s.max()
    return ['background-color: yellow' if v else '' for v in is_max]

# Tabulator widgets
styled_fz = pn.widgets.Tabulator(style_df, frozen_columns=[0])
styled = pn.widgets.Tabulator(style_df)

# Apply styling
styled.style.map(color_negative_red).apply(highlight_max)
styled_fz.style.map(color_negative_red).apply(highlight_max)

# Layout to compare output
pn.Column(
    "NO FROZEN COL",
    styled,
    "FROZEN COL",
    styled_fz,
    "Style Object: Frozen",
    styled_fz.style,
    "Style Object: Non-Frozen",
    styled.style,
)

Stack traceback and/or browser JavaScript console output

N/A

Screenshots or screencasts of the bug in action

Image

If you want to keep the same order for your column and want to have some frozen columns, you should use :

styled_fz = pn.widgets.Tabulator(style_df, frozen_columns=["index", "A"])

If you want to have the index and the A column frozen.