# Fill handle

> Drag the corner of a selected range to copy values or extend number and date series into neighbouring cells.

The fill handle is the small square at the bottom-right corner of a selected range. Dragging it fills the cells you drag over, exactly like the fill handle in Excel: it repeats values, or continues a series such as `10, 20, 30` or a run of month-end dates.

> **Grid Pro: Paid feature. Fully functional without a key; a license removes the watermark. Pricing: https://docs.birchui.com/getting-started/pricing.md**
>
> The fill handle requires `FillHandleModule` and `RangeSelectionModule` from `@birchui/grid-pro`.

## Enable the fill handle

The handle appears only when range selection is on and a single range is selected.

```ts title="forecast-grid.ts"
import { createGrid, type ColumnDef } from '@birchui/core';
import { RangeSelectionModule, FillHandleModule, ClipboardModule } from '@birchui/grid-pro';

interface ForecastRow {
  id: string;
  account: string;
  month: string;
  forecast: number;
  owner: string;
}

const columns: ColumnDef<ForecastRow>[] = [
  { field: 'account', width: 200 },
  { field: 'month', type: 'date', editable: true },
  { field: 'forecast', type: 'number', editable: true },
  { field: 'owner', editable: true },
];

const api = createGrid(container, {
  columns,
  rows: forecast,
  getRowId: (row) => row.id,
  modules: [RangeSelectionModule, FillHandleModule, ClipboardModule],
  rangeSelection: true,
  fillHandle: true,
});
```

## Using it

1. Select one or more cells.
2. Press on the handle at the range's bottom-right corner and drag up, down, left or right. The cells that will be filled are outlined. Dragging past the edge of the grid scrolls it.
3. Release to fill. Press `Escape` before releasing to cancel.

The fill runs along the direction you drag furthest in, and each column (when filling vertically) or row (when filling horizontally) is filled from its own source values. After the fill, the selection grows to cover the source and the filled cells.

The handle is hidden while a cell is being edited and when more than one range is selected.

## What gets filled

The grid looks at the source values in each column or row and picks one of two modes.

### Series

When the source has two or more values with a constant step, the series continues:

| Source | Filled downwards |
| --- | --- |
| `1, 2` | `3, 4, 5, …` |
| `100, 250` | `400, 550, …` |
| `0.25, 0.5` | `0.75, 1, …` (decimals are preserved, so no `0.7500000001`) |
| `2026-03-02, 2026-03-09` | `2026-03-16, 2026-03-23, …` (weekly) |
| `2026-01-15, 2026-02-15` | `2026-03-15, 2026-04-15, …` (monthly, same day) |
| `2026-01-31, 2026-02-28` | `2026-03-31, 2026-04-30, …` (month ends stay month ends) |
| `09:00, 09:30` on the same day | `10:00, 10:30, …` |

Dragging up or left runs the series backwards from the first source value: `10, 20` filled upwards gives `0, -10, …`.

Dates keep the form your data uses. If the column holds ISO strings such as `'2026-03-15'`, the filled values are ISO strings too; timestamps stay numbers and `Date` objects stay `Date` objects.

### Copy

When there is no constant step, for a single value, for text, or for mixed values, the source values are repeated in order:

| Source | Filled downwards |
| --- | --- |
| `Northwind` | `Northwind, Northwind, …` |
| `Gold, Silver, Bronze` | `Gold, Silver, Bronze, Gold, …` |
| `5` | `5, 5, 5, …` |
| `3, 7, 4` | `3, 7, 4, 3, …` |

### Switching modes

Hold `Ctrl` or `Alt` when you release the handle to invert the choice:

- a series source is copied instead of extended;
- a single number counts up by one: `5` becomes `6, 7, 8, …`;
- a single date advances by one day.

## Which cells change

The fill writes only to editable data cells, exactly like [paste](https://docs.birchui.com/grid-pro/clipboard.md#paste). Read-only cells, group rows and total rows inside the target area are left as they are, and cells that already hold the target value are skipped.

Each changed cell fires `cellValueChanged` with `source: 'fill'`:

```ts
api.on('cellValueChanged', ({ colId, newValue, source }) => {
  if (source === 'fill') console.log(`filled ${colId} with ${String(newValue)}`);
});
```

Values are written through the column's `valueSetter` when it has one, so derived fields stay consistent.

## Styling

The handle is an element with the class `lq-fill-handle`, sized by `--lq-pro-fill-handle-size` (7 pixels by default). The preview outline uses `--lq-pro-fill-preview-edge` and `--lq-pro-fill-preview-bg`. Override them on the grid or a parent:

```css
.lq-grid {
  --lq-pro-fill-handle-size: 9px;
  --lq-pro-fill-preview-edge: #0f766e;
}
```

## Keyboard and single-pointer alternatives

Select the source cells and the cells to fill as one range (with `Shift` + arrow keys or `Shift` + click), then:

| Key | Context menu item | Result |
| --- | --- | --- |
| <kbd>Ctrl</kbd>+<kbd>D</kbd> | Fill down | Copies the top row of the range into the rows below it |
| <kbd>Ctrl</kbd>+<kbd>R</kbd> | Fill right | Copies the left column of the range into the columns to its right |
| <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>D</kbd> | Fill series down | Continues a series from the top row: a detected series continues, a single number or date steps by 1 |
| <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>R</kbd> | Fill series right | The same, from the left column |

On macOS, <kbd>Cmd</kbd> works wherever <kbd>Ctrl</kbd> is listed. The context menu items appear when you right-click
a cell or press the context menu key or <kbd>Shift</kbd>+<kbd>F10</kbd>, so the fill works without dragging. These
commands skip read-only cells and write with the `'fill'` source, like the handle.

The [clipboard](https://docs.birchui.com/grid-pro/clipboard.md) remains another option: copy a value, select the target range and paste. A single
copied value fills the whole range.
