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

# display

APISummary
## Introduction

In Lynx, the `display` only determines the internal display type of the element (how to layout the child elements), and does not determine the external display type (whether the element is considered a [block-level element](https://developer.mozilla.org/en-US/docs/Glossary/Block-level_content) or an [inline-level element](https://developer.mozilla.org/en-US/docs/Glossary/Inline-level_content)).

Lynx does not have [flow layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flow_layout) and does not support the `display: block/inline` syntax. All Lynx elements are [block-level element](https://developer.mozilla.org/en-US/docs/Glossary/Block-level_content), except for the elements inside the `<text>` component.

:::info
[Linear layout](/next/guide/ui/layout/linear-layout.md) is the default layout for elements in Lynx. You can set `defaultDisplayLinear: false` in the project configuration to change the default layout to \[flexible box layout].
:::

## Examples

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

**Entry:** `src/display`
**Bundle:** `dist/display.lynx.bundle`

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

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

  return (
    <scroll-view scroll-orientation="vertical">
      <view className="fixed_area" style={fixedAreaStyle}>
        <text>flex</text>
        <view className="container" style={{ display: "flex" }}>
          <text className="item">1</text>
          <text className="item">2</text>
        </view>

        <text>linear</text>
        <view className="container" style={{ display: "linear", linearOrientation: "horizontal" }}>
          <text className="item">1</text>
          <text className="item">2</text>
        </view>

        <text>relative</text>
        <view className="container" style={{ display: "relative" }}>
          <text
            className="item"
            style={{
              // @ts-expect-error TODO(types): Support relativeId in `@lynx-js/types`
              relativeId: "1",
            }}
          >
            1
          </text>
          <text
            className="item"
            style={{
              // @ts-expect-error TODO(types): Support relativeRightOf in `@lynx-js/types`
              relativeRightOf: "1",
            }}
          >
            2
          </text>
        </view>
      </view>
    </scroll-view>
  );
};

root.render(<Display />);

```

v0.11.0



## Syntax

```css
display: flex;
display: none;
display: linear;
display: relative;
display: grid;
```

### Values

#### `flex`

See more in [flexible box layout](/next/guide/ui/layout/flexible-box-layout.md).

#### `linear`

[linear layout](/next/guide/ui/layout/linear-layout.md) is the default Layout model developed by Lynx. It has best **performance** in all types of layout in Lynx.

:::info
`<scroll-view>` is forced to be a linear layout, in which case `<scroll-view>` is formatted as a normal linear view. Both the alignment attribute and [linear-weight](/next/api/css/properties/linear-weight.md) take effect. And `scroll-x`/`scroll-y` will change the main axis to horizontal and vertical respectively. (The actual conversion is determined by whether to set `scroll-x`/`scroll-y`.)
:::

#### `none`

Element and its descents will be resized to 0x0.

:::info
If the parent element of the `<text>` element is set to `display:none` and the `<text>` element is still rendered visible, please add [`overflow:hidden`](/next/api/css/properties/overflow.md) to the corresponding parent element. We will fix this issue in the future.
:::

#### `grid`

Element will layout according to the grid layout layout model.

#### `relative`

Relative layout is a Layout model developed by Lynx.

Element will layout according to the relative layout model. Relative layout is a layout that displays children in relative positions, where each view's position can be specified relative to sibling elements (for example, to the left or below another view) or relative to the parent's area (e.g. align at bottom, left or center).

## Formal definition

| Initial value | `linear` |
| Applies to | all elements |
| Inherited | no |
| Animatable |  |


## Formal syntax

```
display = none | linear | flex | grid | relative
```

## Differences from the Web

- In Lynx, the `display` only determines the internal display type of the element (how to layout the child elements), and does not determine the external display type (whether the element is considered a [block-level element](https://developer.mozilla.org/en-US/docs/Glossary/Block-level_content) or an [inline-level element](https://developer.mozilla.org/en-US/docs/Glossary/Inline-level_content)).
- [relative layout](/next/guide/ui/layout/relative-layout.md) and [linear layout](/next/guide/ui/layout/linear-layout.md) are Layout models developed by Lynx.
- Lynx does not have [flow layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flow_layout) and does not support the `display: block/inline` syntax. All Lynx elements are [block-level element](https://developer.mozilla.org/en-US/docs/Glossary/Block-level_content), except for the elements inside the `<text>` component.
- `inline-block`, `inline-flex`, `inline-grid` are not supported.

## Compatibility

**Compatibility Table**

**Query:** `css.properties.display`

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| display | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| api1 | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| relative | Yes (1.6) | Yes (3.4) | Yes (1.6) | Yes (1.6) | Yes (1.6) | No |
| grid | Yes (2.1) | Yes (3.4) | Yes (2.1) | Yes (2.1) | Yes (2.1) | Yes |
| unsupported&#95;value | No | No | No | No | No | Unknown |

**`display`**

**Specifications:**

**`api1`**

<code>none</code>, <code>flex</code>, <code>linear</code>

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

**`relative`**

<code>relative</code>

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

**`grid`**

<code>grid</code>

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

**`unsupported_value`**

<code>inline</code> and <code>block</code>

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


## FAQ

- `<scroll-view>` is forced to be a linear layout, in which case `<scroll-view>` is formatted as a normal linear view. Both the alignment attribute and [`linear-weight`](/next/api/css/properties/linear-weight.md) take effect. And `scroll-x`/`scroll-y` will change the main axis to horizontal and vertical respectively. (The actual conversion is determined by whether to set `scroll-x`/`scroll-y`.)
