> 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-self

APISummary
## Introduction

In flex and [linear](/next/guide/ui/layout/linear-layout.md) layout, `align-self` will align the elements in the current container on the **cross axis**. In grid layout, `align-self` controls the alignment of child elements along the **block axis** within their grid area, and `align-self` overrides the existing value of [`align-items`](/next/api/css/properties/align-items.md).

For flexible box layout, if any child element's cross-axis [`margin`](/next/api/css/properties/margin.md) is set to auto, `align-self` 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-self`
**Bundle:** `dist/align-self.lynx.bundle`

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

const AlignSelf = () => {
  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}>
        <view style={{ width: "100%", height: "100%", flexDirection: "column" }}>
          <text className="title">align-self: stretch;</text>
          <view style={{ display: "flex", flexDirection: "column", alignItems: "center" }}>
            <text style={itemStyle}>X</text>
            <text style={{ ...itemStyle, alignSelf: "stretch" }}>X</text>
            <text style={itemStyle}>X</text>
          </view>

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

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

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

root.render(<AlignSelf />);

```

v0.11.0



## Syntax

### Values

#### `auto`

**Default value**. Aligns according to the parent's [`align-items`](/next/api/css/properties/align-items.md) value.

#### `stretch`

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, the item is centered along the cross axis.

In [grid](/next/guide/ui/layout/grid-layout.md) layout, the item is centered along the block axis within its grid area.

#### `start`

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

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

#### `end`

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

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

#### `flex-start`

Behaves the same as `start`.

#### `flex-end`

Behaves the same as `end`.

#### `baseline`

The item participates in baseline alignment. Currently only supported in flexible box layout.

## Formal definition

| Initial value | auto |
| Applies to | flex/grid/linear items |
| Inherited | no |
| Animatable | no |


## Formal syntax

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

## Differences from the Web

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

1. `normal`, `self-start` and `self-end` are not supported.

## Compatibility

**Compatibility Table**

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

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| align-self | 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.nested&#95;value&#95;1 | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| supported&#95;in&#95;flex&#95;layout.nested&#95;value&#95;3 | 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) | No |
| supported&#95;in&#95;linear&#95;layout.nested&#95;value&#95;1 | Yes (2.2) | Yes (3.4) | Yes (2.2) | Yes (2.2) | Yes (2.2) | Yes |
| supported&#95;in&#95;linear&#95;layout.nested&#95;value&#95;2 | Yes (2.16) | Yes (3.4) | Yes (2.16) | Yes (2.16) | Yes (2.16) | Yes |
| supported&#95;in&#95;linear&#95;layout.nested&#95;value&#95;3 | 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.nested&#95;value&#95;1 | Yes (2.1) | Yes (3.4) | Yes (2.1) | Yes (2.1) | Yes (2.1) | Yes |
| supported&#95;in&#95;grid&#95;layout.nested&#95;value&#95;2 | 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-self`**

**Specifications:**

**`supported_in_flex_layout`**

Supported in Flexible Box Layout

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

**`supported_in_flex_layout.nested_value_1`**

<code>auto</code>, <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/56-align-self.json)

**`supported_in_flex_layout.nested_value_3`**

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

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

**`supported_in_flex_layout.baseline`**

<code>baseline</code>

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

**`supported_in_linear_layout`**

Supported in Linear Layout

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

**`supported_in_linear_layout.nested_value_1`**

<code>auto</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/56-align-self.json)

**`supported_in_linear_layout.nested_value_2`**

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

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

**`supported_in_linear_layout.nested_value_3`**

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

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

**`supported_in_grid_layout`**

Supported in Grid Layout

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

**`supported_in_grid_layout.nested_value_1`**

<code>auto</code>, <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/56-align-self.json)

**`supported_in_grid_layout.nested_value_2`**

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

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

**`supported_in_grid_layout.baseline`**

<code>baseline</code>

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

**`normal`**

<code>normal</code>

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

