chriddyp · GitHub

In some cases, text can be very long within a cell and a user may wish to constrain the height of the cell.

This currently requires a css= workaround. It would be nice if it didn't.

From the docs, this is:

dash_table.DataTable(
    style_data={
        'whiteSpace': 'normal',
    },
    data=df_moby_dick.to_dict('records'),
    columns=[{'id': c, 'name': c} for c in df_moby_dick.columns],
    css=[{
        'selector': '.dash-spreadsheet td div',
        'rule': '''
            line-height: 15px;
            max-height: 30px; min-height: 30px; height: 30px;
            display: block;
            overflow-y: hidden;
        '''
    }],
    tooltip_data=[
        {
            column: {'value': str(value), 'type': 'markdown'}
            for column, value in row.items()
        } for row in df_moby_dick.to_dict('rows')
    ],
    tooltip_duration=None
)

Let's comment on this issue if we change this example and/or provide an alternative.

Read the original on github.com ↗