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

# align-items

APISummary
## Introduction

`align-items` property sets the [`align-self`](/next/api/css/properties/align-self.md) value on all direct children as a group. In flexible box layout and [linear layout](/next/guide/ui/layout/linear-layout.md), it controls the alignment of items on the **cross axis**. In grid layout, it controls the alignment of items on the **block axis** within their grid area.

For flexible box layout, if any child element's cross-axis [`margin`](/next/api/css/properties/margin.md) is set to `auto`, `align-items` will be ignored.

:::info
For grid layout, Lynx doesn't support `writing-mode`, so the block axis is the vertical axis.
:::

## Examples

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

**Entry:** `src/align-items`
**Bundle:** `dist/align-items.lynx.bundle`

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

const AlignItems = () => {
  const fixedAreaStyle = {
    width: "100%",
    height: "100%",
    flexDirection: "column" as const,
  };

  const itemStyle = {
    width: "50px",
    height: "50px",
    margin: "5px",
    backgroundColor: "#4e98f4",
    color: "#ffffff",
    textAlign: "center" as const,
    lineHeight: "50px",
  };

  return (
    <scroll-view className="root" scroll-orientation="vertical">
      <view className="fixed_area" style={fixedAreaStyle}>
        <text className="title">align-items: stretch;</text>
        <view style={{ display: "flex", flexDirection: "column", alignItems: "stretch" }}>
          <text style={itemStyle}>X</text>
          <text style={itemStyle}>X</text>
          <text style={itemStyle}>X</text>
        </view>

        <text className="title">align-items: center;</text>
        <view style={{ display: "flex", flexDirection: "column", alignItems: "center" }}>
          <text style={itemStyle}>X</text>
          <text style={itemStyle}>X</text>
          <text style={itemStyle}>X</text>
        </view>

        <text className="title">align-items: flex-start;</text>
        <view style={{ display: "flex", flexDirection: "column", alignItems: "flex-start" }}>
          <text style={itemStyle}>X</text>
          <text style={itemStyle}>X</text>
          <text style={itemStyle}>X</text>
        </view>

        <text className="title">align-items: flex-end;</text>
        <view style={{ display: "flex", flexDirection: "column", alignItems: "flex-end" }}>
          <text style={itemStyle}>X</text>
          <text style={itemStyle}>X</text>
          <text style={itemStyle}>XS</text>
        </view>
      </view>
    </scroll-view>
  );
};

root.render(<AlignItems />);

```

v0.11.0



## Syntax

### Values

#### `stretch`

**Default value**. If items are smaller than the container in the **cross-axis** direction (block axis in [grid](/next/guide/ui/layout/grid-layout.md) layout), items with unspecified dimensions (height/width) or set to `auto` will be stretched to match the height of the row or width of the column. These items still maintain their aspect ratio constraints.

#### `center`

In flex and [linear](/next/guide/ui/layout/linear-layout.md) layouts, items are centered along the cross axis.

In [grid](/next/guide/ui/layout/grid-layout.md) layout, items are centered along the block axis within their grid area.

:::info
In flexible box layout, if an item's cross-axis size is larger than the flex container, it will overflow equally in both directions.
:::

#### `start`

In flex and [linear](/next/guide/ui/layout/linear-layout.md) layouts, items are aligned at the start of the cross axis.

In [grid](/next/guide/ui/layout/grid-layout.md) layout, items are aligned with the start edge of their grid area along the block axis.

#### `end`

In flex and [linear](/next/guide/ui/layout/linear-layout.md) layouts, items are aligned at the end of the cross axis.

In [grid](/next/guide/ui/layout/grid-layout.md) layout, items are aligned with the end edge of their grid area along the block axis.

#### `flex-start`

Behaves the same as `start`.

#### `flex-end`

Behaves the same as `end`.

#### `baseline`

All flex items are aligned such that their flex container baselines align. The item with the largest distance between its cross-start margin edge and its baseline is flushed with the cross-start edge of the line. Currently only supported in flexible box layout.

#### `auto` deprecated

Equivalent to `stretch`. Not recommended, as this value doesn't exist in Web.

## Formal definition

| Initial value | stretch |
| Applies to | flex/grid/linear containers |
| Inherited | no |
| Animatable | no |


## Formal syntax

```
align-items = stretch | center | start | end | flex-start | flex-end | baseline | auto
```

## Differences from the Web

[mdn: align-items](https://developer.mozilla.org/en/docs/Web/CSS/align-items)

1. `normal`, `self-start` and `self-end` are not supported. Initial value is `stretch`.

## Compatibility

**Compatibility Table**

**Query:** `css.properties.align-items`

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| align-items | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| supported&#95;in&#95;flex&#95;layout | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| supported&#95;in&#95;flex&#95;layout.stretch-flex-start-flex-end-center | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| supported&#95;in&#95;flex&#95;layout.start-and-end | Yes (2.16) | Yes (3.4) | Yes (2.16) | Yes (2.16) | Yes (2.16) | Yes |
| supported&#95;in&#95;flex&#95;layout.baseline | Yes (2.6) | Yes (3.4) | Yes (2.7) | Yes (2.7) | Yes (2.7) | Yes |
| supported&#95;in&#95;linear&#95;layout | Yes (2.2) | Yes (3.4) | Yes (2.2) | Yes (2.2) | Yes (2.2) | Yes |
| supported&#95;in&#95;linear&#95;layout.flex-start-flex-end-center | Yes (2.2) | Yes (3.4) | Yes (2.2) | Yes (2.2) | Yes (2.2) | Yes |
| supported&#95;in&#95;linear&#95;layout.start-and-end | Yes (2.16) | Yes (3.4) | Yes (2.16) | Yes (2.16) | Yes (2.16) | Yes |
| supported&#95;in&#95;linear&#95;layout.baseline-and-stretch | No | No | No | No | No | No |
| supported&#95;in&#95;grid&#95;layout | Yes (2.1) | Yes (3.4) | Yes (2.1) | Yes (2.1) | Yes (2.1) | Yes |
| supported&#95;in&#95;grid&#95;layout.stretch-flex-start-flex-end-center | Yes (2.1) | Yes (3.4) | Yes (2.1) | Yes (2.1) | Yes (2.1) | Yes |
| supported&#95;in&#95;grid&#95;layout.start-and-end | Yes (2.16) | Yes (3.4) | Yes (2.16) | Yes (2.16) | Yes (2.16) | Yes |
| supported&#95;in&#95;grid&#95;layout.baseline | No | No | No | No | No | Yes |
| normal | No | No | No | No | No | Yes |

**`align-items`**

**Specifications:**

**`supported_in_flex_layout`**

Supported in Flexible Box Layout

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

**`supported_in_flex_layout.stretch-flex-start-flex-end-center`**

<code>stretch</code>, <code>flex-start</code>, <code>flex-end</code>, <code>center</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

**`supported_in_flex_layout.start-and-end`**

<code>start</code> and <code>end</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

**`supported_in_flex_layout.baseline`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

**`supported_in_linear_layout`**

Supported in Linear Layout

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

**`supported_in_linear_layout.flex-start-flex-end-center`**

<code>flex-start</code>, <code>flex-end</code>, <code>center</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

**`supported_in_linear_layout.start-and-end`**

<code>start</code> and <code>end</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

**`supported_in_linear_layout.baseline-and-stretch`**

<code>baseline</code> and <code>stretch</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

**`supported_in_grid_layout`**

Supported in Grid Layout

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

**`supported_in_grid_layout.stretch-flex-start-flex-end-center`**

<code>stretch</code>, <code>flex-start</code>, <code>flex-end</code>, <code>center</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

**`supported_in_grid_layout.start-and-end`**

<code>start</code> and <code>end</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

**`supported_in_grid_layout.baseline`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

**`normal`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/55-align-items.json)

