Adding styles to a specific header cell in AgGrid

2.4k Views Asked by At

I am working on AgGrid (AgGridReact component) with one of the header cells having a checkbox for 'select all'

Please refer the image here

Was wondering if there is a way to pad/margin the select-all checkbox in alignment with the checkboxes in the column.

1

There are 1 best solutions below

0
On BEST ANSWER

You can add headerClass to a specific column definition and apply the css style as usual

const columnDefs = [
  {
    checkboxSelection: true,
    headerCheckboxSelection: true,
    headerClass: "checkbox",
    width: 70
  },
  {
    headerName: "ID",
    field: "id",
    width: 70
  },
  ...
}

Css

/* add role attribute to increase specificity */
.ag-header-cell.checkbox[role="presentation"] {
  padding: 20px;
}

Live Demo

Edit 64273758/adding-padding-margin-to-a-specific-header-cell-in-ag-grid