# Quick Search Matching Styles

Canonical page: https://www.adaptabletools.com/docs/handbook-quick-search-matching-styles

- AdapTable allows users to configure the highlighting style of matching cells of Quick Search
- This can be done both at design-time and run-time

When Quick Search runs, AdapTable provides 3 different Styles to highlight matching cells and search text.

All use the common [Adaptable Style](https://www.adaptabletools.com/docs/ui-tutorial-providing-adaptable-style/index.md) object which includes multiple font properties and fore, back and border colours

The default Quick Search colours are theme variables: `--ab-color-quick-search-match` / `--ab-color-quick-search-match-foreground` for matching text, and `--ab-color-quick-search-current-match` / `--ab-color-quick-search-current-match-foreground` for the current match

See [Customising an AdapTable Theme](https://www.adaptabletools.com/docs/handbook-theming-custom/index.md) and [Providing a Custom Colour Palette](https://www.adaptabletools.com/docs/ui-tutorial-custom-colour-palette/index.md) for more information

|      Property Name      |                      Highlights                      |                                                 Default                                                  |
| :---------------------: | :--------------------------------------------------: | :------------------------------------------------------------------------------------------------------: |
|    `CellMatchStyle`     |              All Text in Matching Cells              |                                                   None                                                   |
|    `TextMatchStyle`     |              Matching text within Cell               |          Quick Search match —           |
| `CurrentTextMatchStyle` | Matching text in current Cell (when cycling results) | Quick Search current match —  |

- `CellMatchStyle` is optional until **Cell Match** is set in the UI
- In the [Server-Side Row Model](https://www.adaptabletools.com/docs/dev-guide-row-models-server-searching/index.md), only the `CellMatchStyle` is available (whole-cell highlight)

## Design Time

Developers can provide an alternative Style for all 3 properties in [Quick Search Initial State](https://www.adaptabletools.com/docs/technical-reference-quick-search/index.md).

### Setting Matching Styles via Initial Adaptable State

All 3 Styles are of type [Adaptable Style](https://www.adaptabletools.com/docs/ui-tutorial-providing-adaptable-style/index.md) used in many places in AdapTable, allowing developers to provide:

- Fore, Back and Border Colours - each by name, hex or rgb(a)
- Font Properties (e.g. Bold, Italic etc)

Provide a Style for the whole text in Matching Cells.

Provide a Style for just the matching text in Matching Cells.

Provide a Style for the matching text in the Current Matching Cell.

This is used when cycling through the result set.

```ts [[1, 3, "CellMatchStyle"], [2, 7, "TextMatchStyle"], [3, 11, "CurrentTextMatchStyle"]]
const initialState: InitialState = {
  QuickSearch: {
    CellMatchStyle: {
      ForeColor: 'rgba(0,0,255,0.1)', //rgba value (rgb also possible)
      BackColor: 'var(--ab-color-palette-19)', //Name value
    },
    TextMatchStyle: {
      ForeColor: 'var(--ab-color-palette-24)',
      FontStyle: 'Italic',
    },
    CurrentTextMatchStyle: {
      BackColor: 'Pink',
      FontWeight: 'Bold',
    },
  },
};
```

**Example: Quick Search Matching Styles**

Setting Quick Search Matching Styles

- In this demo we have set all 3 Quick Search Matching Styles
  - `CellMatchStyle` - BackColor: 'var(--ab-color-palette-17)' and ForeColor: 'var(--ab-color-palette-21)'
  - `TextMatchStyle` - BackColor: 'var(--ab-color-palette-28)', ForeColor: 'var(--ab-color-palette-14)' and Italics
  - `CurrentTextMatchStyle` - Bold and large text

- Run different searches and see the style applied
- Cycle through the result set to see the `CurrentTextMatchStyle` be applied

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: 'Quick Search Matching Styles',
  initialState: {
    Dashboard: {
      ModuleButtons: ['QuickSearch'],
    },
    QuickSearch: {
      QuickSearchText: 'Java',
      CellMatchStyle: {
        BackColor: 'var(--ab-color-palette-17)',
        ForeColor: 'var(--ab-color-palette-21)',
      },
      TextMatchStyle: {
        BackColor: 'var(--ab-color-palette-28)',
        ForeColor: 'var(--ab-color-palette-14)',
        FontStyle: 'Italic',
      },
      CurrentTextMatchStyle: {
        FontWeight: 'Bold',
        FontSize: 'Large',
      },
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['QuickSearch'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'topics',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## Run Time

Run-time users can configure Quick Search matching styles in the Quick Search section of the [Settings Panel](https://www.adaptabletools.com/docs/ui-settings-panel/index.md).

- **Client-side row models** — three tabs: `Text Match`, `Current Match`, and `Cell Match`
- **Server-side row model** — `Cell Matching Style` only (whole-cell highlight).

The UI allows users to select colours from the theme palette and font properties.

### Setting Quick Search Matching Styles in the Settings Panel

These are the steps involved:

There are 3 Colours that can be selected for a Style:

- Back Colour
- Fore (i.e. font) Colour
- Border Colour

The Settings Panel displays the theme colour palette.

- Colours are taken from theme CSS variables — see [Providing a Custom Colour Palette](https://www.adaptabletools.com/docs/ui-tutorial-custom-colour-palette/index.md)

There are 3 Font Properties that can be selected:

- Bold
- Italic
- Font Size

If `Font Size` is selected, another dropdown appears allowing the user to select from:

- XSmall
- Small
- Medium
- Large
- XLarge

Defaults are resolved at run time and are **not** written to Adaptable State until you customise them (via Initial State, Settings Panel, or API). By default, only matching text is highlighted; set **Cell Match** to add a whole-cell background.
