> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# grid-auto-flow

APISummary
## Introduction

The `grid-auto-flow` CSS property controls how the auto-placement algorithm works, specifying exactly how auto-placed items get flowed into the grid.

## Examples

**This is an example below: css-api**

**Entry:** `src/grid-auto-flow`
**Bundle:** `dist/grid-auto-flow.lynx.bundle`

```tsx
import { root } from "@lynx-js/react";
import "./index.scss";

const GridAutoFlow = () => {
  const titleStyle = {
    fontSize: "45rpx" as const,
    fontWeight: "900" as const,
    alignSelf: "center" as const,
    color: "linear-gradient(to right, rgb(255,53,26), rgb(0,235,235))" as const,
  };

  return (
    <>
      <text style={titleStyle}>grid-auto-flow: row</text>
      <view className="container" style={{ gridAutoFlow: "row" }}>
        <text className="item" style={{ gridColumnStart: "span 2" }}>ONE</text>
        <text className="item" style={{ gridColumnStart: "span 2" }}>TWO</text>
        <text className="item">THREE</text>
        <text className="item">FOUR</text>
        <text className="item">FIVE</text>
      </view>

      <text style={titleStyle}>grid-auto-flow: column</text>
      <view className="container" style={{ gridAutoFlow: "column" }}>
        <text className="item" style={{ gridColumnStart: "span 2" }}>ONE</text>
        <text className="item" style={{ gridColumnStart: "span 2" }}>TWO</text>
        <text className="item">THREE</text>
        <text className="item">FOUR</text>
        <text className="item">FIVE</text>
      </view>
    </>
  );
};

root.render(<GridAutoFlow />);

```

v0.11.0



## Syntax

```css
grid-auto-flow: row;
grid-auto-flow: column;
grid-auto-flow: row dense;
grid-auto-flow: column dense;
grid-auto-flow: dense;
```

### Values

This property may take one of two forms:

a single keyword: one of row, column, or dense.

two keywords: row dense or column dense.

- `row`

  **Default value**. Items are placed by filling each row in turn, adding new rows as necessary. If neither row nor column is provided, row is assumed.

- `column`

  Items are placed by filling each column in turn, adding new columns as necessary.

- `dense`

  "dense" packing algorithm attempts to fill in holes earlier in the grid, if smaller items come up later. This may cause items to appear out-of-order, when doing so would fill in holes left by larger items.

  If it is omitted, a "sparse" algorithm is used, where the placement algorithm only ever moves "forward" in the grid when placing items, never backtracking to fill holes. This ensures that all of the auto-placed items appear "in order", even if this leaves holes that could have been filled by later items.

## Formal definition

| Initial value | row |
| Applies to | grid containers |
| Inherited | no |
| Animatable |  |


## Formal syntax

```
grid-auto-flow = [ row | column ] || dense
```

## Compatibility

**Compatibility Table**

**Query:** `css.properties.grid-auto-flow`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/185-grid-auto-flow.json) · [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| grid-auto-flow | Yes (2.1) | Yes (3.4) | Yes (2.1) | Yes (2.1) | Yes (2.1) | Yes |

**`grid-auto-flow`**

**Specifications:**

