Skip to content

CSS custom property support for column widths #335

@tiwe-ppi

Description

@tiwe-ppi

Description

Our application supports different themes for different customers. To achieve this, we use CSS custom properties to define column widths, with each theme having its own set of values. So basically this:

{
    columns: [
        { width: "var(--foo-bar)", /* ... */ }
    ],
    // ...
}

This approach worked well with DataTables 1.11.5. However, after upgrading to DataTables 2.2.2, it no longer functions as expected. I suspect this issue arises because regular expressions are now used to parse the width values, likely for optimization or parsing reasons.

Workaround

We have devised a workaround by pre-computing the pixel values for column widths in JavaScript before initializing the table. While this is a feasible solution, it adds extra complexity to our code.

Request

Is there a possibility to officially support the use of CSS custom properties for column widths in future versions of DataTables?
I think this would be a nice feature for datatables but as we have a functioning workaround we can live without it.

Thank you for considering this suggestion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions