Skip to content

Conversation

george-cz
Copy link
Contributor

Feature: Configurable Default Column Padding for DataGrid Resizable Columns

Overview

This PR introduces a new option to configure the default column padding for resizable columns in the DataGrid component. This enhancement gives consumers the option to update the value used for resizable columns calculation for their custom designs or use cases.

Changes

  • Adds a defaultColumnPadding option to DataGrid and related types, allowing consumers to specify the amount of padding applied to columns when resizable columns are enabled.
  • Updates internal logic and type definitions to support the new configuration.
  • Maintains backward compatibility: if no value is provided, the previous default padding is used.

Usage

<DataGrid
  columns={columns}
  items={items}
  resizableColumns
  resizableColumnsOptions={{
      autoFitColumns: false,
      defaultColumnPadding: 0,
  }}
/>

Additional Notes

  • This option also enables a workaround for #35234:
    When using box-sizing: border-box on DataGrid cells, setting defaultColumnPadding={0} eliminates the extra padding involved in the calculation of column widths.
  • No breaking changes; existing usage without the new prop will continue to work as before.

@george-cz george-cz requested a review from a team as a code owner September 26, 2025 10:57
@george-cz
Copy link
Contributor Author

One note - I'm not sure if this is a good idea.

We already have padding option per column, that can be specified in columnSizingOptions prop.

Also, the original issue already has a workaround (setting box-sizing: content-box on the cells.

I will discuss with the team if we want to add this, as it adds more surface area to maintain.

Copy link

Pull request demo site: URL

resizableColumnsOptions?: {
/**
* If true, columns will be auto-fitted to the container width.
* @default true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-react-components/Charts-DonutChart 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Charts-DonutChart.Dynamic - RTL.default.chromium.png 30793 Changed
vr-tests-react-components/Charts-DonutChart.Dynamic.default.chromium.png 27053 Changed
vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.chromium.png 728 Changed
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 64 Changed
vr-tests-react-components/TagPicker 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled - RTL.disabled input hover.chromium.png 635 Changed
vr-tests-react-components/TagPicker.disabled - High Contrast.disabled input hover.chromium.png 1321 Changed
vr-tests-react-components/TagPicker.disabled.disabled input hover.chromium.png 678 Changed

There were 3 duplicate changes discarded. Check the build logs for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant