plotly / plotly/dash

[BUG] merge_duplicate_headers breaks style_cell_conditional

Open
#3,283 3 comments 0 reactions 1 assignee View on GitHub

@T4rk1n is already working on this.

Since Jun 3, 2025.

bug P2
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

There were earlier bugs report regarding merge_duplicate_headers Issue1877 and it seems like there are still some left. I am not yet at 3.x but i found nothing regarding this in the changelog

dash                      2.18.2
dash-bootstrap-components 1.2.1
dash-core-components      2.0.0
dash-extensions           1.0.1
dash-html-components      2.0.0
dash-table                5.0.0

Describe the bug
Wrong black bold lines when using merge_duplicate_headers and style_cell_conditional.

Expected behavior
No bold black lines in the wrong columns.

Minimal Example

import dash
from dash import Dash, dash_table, html
import pandas as pd

# Sample data
data = {
    'Group A': ['Alice', 'Bob'],
    'Group A.1': [10, 20],
    'Group B': ['X', 'Y'],
    'Group B.1': [100, 200],
    'Group B.2': [1.1, 2.2]
}

# Create DataFrame
df = pd.DataFrame(data)

# Define columns with headers as lists for multi-level headers
columns = [
    {'name': ['Name', 'Person'], 'id': 'Group A'},
    {'name': ['Name', 'Score'], 'id': 'Group A.1'},
    {'name': ['Details', 'Code'], 'id': 'Group B'},
    {'name': ['Details', 'Value 1'], 'id': 'Group B.1'},
    {'name': ['Details', 'Value 2'], 'id': 'Group B.2'},
]

# Define style for bold black borders
style_cell_conditional = [
    {
        'if': {'column_id': col},
        'borderRight': '5px solid black',
        'fontWeight': 'bold'
    } for col in ['Group A.1', 'Group B.1']  # Columns to highlight
]

# Dash app
app = Dash(__name__)

app.layout = html.Div([
    dash_table.DataTable(
        data=df.to_dict('records'),
        columns=columns,
        merge_duplicate_headers=True,
        style_cell={'textAlign': 'center'},
        style_cell_conditional=style_cell_conditional
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.