# Styling Column Headers

Canonical page: https://www.adaptabletools.com/docs/handbook-column-formatting-headers

- It is possible to style and format Column Headers
- Headers use a Style and an optional string Display Format — they cannot use a Condition

Format Column Styles and Display Formats can also be applied to Column Headers.

You **cannot apply** a [Condition](https://www.adaptabletools.com/docs/handbook-column-formatting-conditions/index.md) to Column Headers (there is only one header value and nothing to evaluate)

This is done through the `Target` property of the FormatColumn object which can be either:
- `cell` (the default) - applies the Format just to the Column's data cells
- `columnHeader` - applies the Format only to the Column Header

- All Column Headers **always** only use a [String Display Format](https://www.adaptabletools.com/docs/handbook-column-formatting-display-format-string/index.md) (as the Column Header value is a string)
- This applies also to Numeric and Date columns (whose cells use [Number](https://www.adaptabletools.com/docs/handbook-column-formatting-display-format-number/index.md) and 
[Date](https://www.adaptabletools.com/docs/handbook-column-formatting-display-format-date/index.md) Display Formats respectively)

**Example: Styling & Formatting Column Headers**

Formatting and Styling Column Headers

- This example contains 3 Format Column Styles which have been applied to Column Headers only:
  - `All` Columns are centre-aligned
  - `Language` Column is blue, capitalised and italicised
  - `Numeric` Columns have a distinctive background

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Formatting Column Headers',
  initialState: {
    Dashboard: {
      ModuleButtons: ['FormatColumn'],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'license',
            'github_stars',
            'closed_issues_count',
            'created_at',
            'closed_pr_count',
            'updated_at',
            'week_issue_change',
            'github_watchers',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'style-all',
          Scope: {
            All: true,
          },
          Style: {
            Alignment: 'Center',
          },
          Target: 'columnHeader',
        },
        {
          Name: 'formatColumn-number',
          Scope: {
            DataTypes: ['number'],
          },
          Style: {
            BackColor: 'var(--ab-color-palette-22)',
            ForeColor: 'var(--ab-color-palette-17)',
          },
          Target: 'columnHeader',
        },
        {
          Name: 'formatColumn-language',
          Scope: {
            ColumnIds: ['language'],
          },
          Style: {
            ForeColor: 'LightBlue',
            FontWeight: 'Bold',
            FontStyle: 'Italic',
            Alignment: 'Center',
          },
          DisplayFormat: {
            Formatter: 'StringFormatter',
            Options: {
              Case: 'Upper',
            },
          },
          Target: 'columnHeader',
        },
      ],
    },
  },
};
```
