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

# justify-content

APISummary
## Introduction

The CSS `justify-content` property defines how distributes space between and around content items along the main-axis of a flexible box layout, [linear](/next/guide/ui/layout/linear-layout.md) container, and the inline axis of a grid layout container.

## Examples

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

**Entry:** `src/justify-content`
**Bundle:** `dist/justify-content.lynx.bundle`

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

const JustifyContent = () => {
  const boxStyle = {
    width: "30px",
    height: "30px",
  };

  const redBoxStyle = {
    ...boxStyle,
    backgroundColor: "red",
  };

  const yellowBoxStyle = {
    ...boxStyle,
    backgroundColor: "yellow",
  };

  const greenBoxStyle = {
    ...boxStyle,
    backgroundColor: "green",
  };

  const blueBoxStyle = {
    ...boxStyle,
    backgroundColor: "blue",
  };

  const flexStartStyle = {
    justifyContent: "flex-start" as const,
  };

  const flexEndStyle = {
    justifyContent: "flex-end" as const,
  };

  const centerStyle = {
    justifyContent: "center" as const,
  };

  const spaceBetweenStyle = {
    justifyContent: "space-between" as const,
  };

  const spaceAroundStyle = {
    justifyContent: "space-around" as const,
  };

  const spaceEvenlyStyle = {
    justifyContent: "space-evenly" as const,
  };

  return (
    <>
      <text>justify-content:flex-start;</text>
      <view className="container" style={flexStartStyle}>
        <view style={redBoxStyle} />
        <view style={yellowBoxStyle} />
        <view style={greenBoxStyle} />
        <view style={blueBoxStyle} />
      </view>

      <text>justify-content:flex-end;</text>
      <view className="container" style={flexEndStyle}>
        <view style={redBoxStyle} />
        <view style={yellowBoxStyle} />
        <view style={greenBoxStyle} />
        <view style={blueBoxStyle} />
      </view>

      <text>justify-content:center;</text>
      <view className="container" style={centerStyle}>
        <view style={redBoxStyle} />
        <view style={yellowBoxStyle} />
        <view style={greenBoxStyle} />
        <view style={blueBoxStyle} />
      </view>

      <text>justify-content:space-between;</text>
      <view className="container" style={spaceBetweenStyle}>
        <view style={redBoxStyle} />
        <view style={yellowBoxStyle} />
        <view style={greenBoxStyle} />
        <view style={blueBoxStyle} />
      </view>

      <text>justify-content:space-around;</text>
      <view className="container" style={spaceAroundStyle}>
        <view style={redBoxStyle} />
        <view style={yellowBoxStyle} />
        <view style={greenBoxStyle} />
        <view style={blueBoxStyle} />
      </view>

      <text>justify-content:space-evenly;</text>
      <view className="container" style={spaceEvenlyStyle}>
        <view style={redBoxStyle} />
        <view style={yellowBoxStyle} />
        <view style={greenBoxStyle} />
        <view style={blueBoxStyle} />
      </view>
    </>
  );
};

root.render(<JustifyContent />);

```

v0.11.0



## Syntax

```css
/* Positional alignment */
justify-content: center; /* Pack items around the center */
justify-content: start; /* Pack items from the start */
justify-content: end; /* Pack items from the end */
justify-content: flex-start; /* Pack flex items from the start */
justify-content: flex-end; /* Pack flex items from the end */

/* Distributed alignment */
justify-content: space-between; /* Distribute items evenly
                                   The first item is flush with the start,
                                   the last is flush with the end */
justify-content: space-around; /* Distribute items evenly
                                   Start and end gaps are half the size of the space
                                   between each item */
justify-content: space-evenly; /* Distribute items evenly
                                   Start, in-between, and end gaps have equal sizes */
justify-content: stretch; /* Distribute items evenly
                                   Stretch 'auto'-sized items to fit
                                   the container */
```

### Values

#### `stretch`

**Default value**.If the combined size of the items along the main axis is less than the size of the alignment container, any auto-sized items have their size increased equally (not proportionally), while still respecting the constraints imposed by [`max-height`](/next/api/css/properties/max-height.md)/[`max-width`](/next/api/css/properties/max-width.md) (or equivalent functionality), so that the combined size exactly fills the alignment container along the main axis.

:::info
For flex boxes, the `stretch` value behaves as `flex-start` or `start`. This is because, in flex boxes, stretching is controlled using the [`flex-grow`](/next/api/css/properties/flex-grow.md) property.

In [linear](/next/guide/ui/layout/linear-layout.md), the `stretch` value behaves as `flex-start` or `start`.
:::

#### `start`

The items are packed flush to each other toward the start edge of the alignment container in the main axis.

#### `end`

The items are packed flush to each other toward the end edge of the alignment container in the main axis.

#### `flex-start`

The items are packed flush to each other toward the edge of the alignment container depending on the flex container's main-start side. This only applies to flexible box layout items. For items that are not children of a flex container, this value is treated like `start`.

#### `flex-end`

The items are packed flush to each other toward the edge of the alignment container depending on the flex container's main-end side. This only applies to flexible box layout items. For items that are not children of a flex container, this value is treated like `end`.

#### `center`

The items are packed flush to each other toward the center of the alignment container along the main axis.

#### `space-between`

The items are evenly distributed within the alignment container along the main axis. The spacing between each pair of adjacent items is the same. The first item is flush with the main-start edge, and the last item is flush with the main-end edge.

#### `space-around`

The items are evenly distributed within the alignment container along the main axis. The spacing between each pair of adjacent items is the same. The empty space before the first and after the last item equals half of the space between each pair of adjacent items.

:::info
In [linear](/next/guide/ui/layout/linear-layout.md), the `space-around` value behaves as `flex-start` or `start`.
:::

#### `space-evenly`

The items are evenly distributed within the alignment container along the main axis. The spacing between each pair of adjacent items, the main-start edge and the first item, and the main-end edge and the last item, are all exactly the same.

:::info
In [linear](/next/guide/ui/layout/linear-layout.md), the `space-evenly` value behaves as `flex-start` or `start`.
:::

## Formal definition

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


## Formal syntax

```
justify-content = <content-distribution> | <content-position>

<content-distribution> =
  space-between  |
  space-around   |
  space-evenly   |
  stretch

<content-position> =
  center      |
  start       |
  end         |
  flex-start  |
  flex-end
```

## Differences from the Web

- `normal` is not supported. Default value is `stretch`.
- `left` and `right` are not supported.
- `baseline`, `first baseline` and `last baseline` are not supported.

## Compatibility

**Compatibility Table**

**Query:** `css.properties.justify-content`

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| justify-content | 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;2 | Yes (2.1) | Yes (3.4) | Yes (2.1) | Yes (2.1) | Yes (2.1) | 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.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;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 |
| unsupported&#95;value&#95;2 | No | No | No | No | No | No |
| normal | No | No | No | No | No | No |
| baseline | No | No | No | No | No | No |

**`justify-content`**

**Specifications:**

**`supported_in_flex_layout`**

Supported in Flexible Box Layout

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/58-justify-content.json)

**`supported_in_flex_layout.nested_value_1`**

<code>flex-start</code>, <code>flex-end</code>, <code>center</code>, <code>space-between</code>, <code>space-around</code>, <code>space-evenly</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/58-justify-content.json)

**`supported_in_flex_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/58-justify-content.json)

**`supported_in_linear_layout`**

Supported in Linear Layout

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/58-justify-content.json)

**`supported_in_linear_layout.nested_value_1`**

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

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/58-justify-content.json)

**`supported_in_grid_layout`**

Supported in Grid Layout

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/58-justify-content.json)

**`supported_in_grid_layout.nested_value_1`**

<code>flex-start</code>, <code>flex-end</code>, <code>center</code>, <code>space-between</code>, <code>space-around</code>, <code>space-evenly</code>, <code>start</code>, <code>end</code>, <code>stretch</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/58-justify-content.json)

**`unsupported_value_2`**

<code>left</code> and <code>right</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/58-justify-content.json)

**`normal`**

<code>normal</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/58-justify-content.json)

**`baseline`**

<code>baseline</code>

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/58-justify-content.json)

