> Native Solid 2 fork. Original documentation and designs © WorkOS; historical posts retain their original context.

# Layout

Get the layout concerns right.

## Layout components

Layout components are used to separate layout responsibilities from content and interactivity. This is _the_ separation of concerns that makes your app maintainable and easy to reason about, and understanding these principles is key to building your interfaces effectively.

### Box

[Box](/themes/docs/components/box) is the most fundamental layout component. Box is used to:

- Provide spacing to child elements.
- Impose sizing constraints on content.
- Control layout behaviour within flex and grid containers.
- Hide content based on screen size using its responsive `display` prop.

### Flex

[Flex](/themes/docs/components/flex) component does everything that Box can do, but comes with an additional set of props to organize items along an axis. It provides convenient access to the CSS [flexbox properties](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)

### Grid

[Grid](/themes/docs/components/grid) is used to organize the content in columns and rows. Like Box and Flex, it’s made to provide convenient access to the underlying CSS [grid properties](https://css-tricks.com/snippets/css/complete-guide-grid/) without any magic of its own.

### Section

[Section](/themes/docs/components/section) provides a consistent vertical spacing between the larger parts of your page content, creating a sense of hierarchy and separation. There’s just a few pre-defined sizes for different spacing levels to keep things simple and consistent.

### Container

[Container](/themes/docs/components/container)’s sole responsibility is to provide a consistent `max-width` to the content it wraps. Like Section, it comes just with a couple of pre-defined sizes that work well with common breakpoints and typical content widths for comfortable reading.

## Common layout props

Each layout component has a set of it’s own specialized props and also a shared set of common layout props. All layout props support [responsive object values](/themes/docs/theme/breakpoints).

### Padding

Padding props can access the [space scale steps](/themes/docs/theme/spacing) or accept any valid [CSS padding value](https://developer.mozilla.org/en-US/docs/Web/CSS/padding).

```jsx
<>

<Box p="4" />

<Box p="100px" />

<Box p={{
    sm: '6',
    lg: '9'
  }} />

</>;
```

| Prop | Type                         | Default |
| ---- | ---------------------------- | ------- |
| `p`  | `Responsive<enum \| string>` | —       |
| `px` | `Responsive<enum \| string>` | —       |
| `py` | `Responsive<enum \| string>` | —       |
| `pt` | `Responsive<enum \| string>` | —       |
| `pr` | `Responsive<enum \| string>` | —       |
| `pb` | `Responsive<enum \| string>` | —       |
| `pl` | `Responsive<enum \| string>` | —       |

### Width

Width props accept any valid [CSS width value](https://developer.mozilla.org/en-US/docs/Web/CSS/width).

```jsx
<>

<Box width="100px" />

<Box width={{
    md: '100vw',
    xl: '1400px'
  }} />

</>;
```

| Prop       | Type                 | Default |
| ---------- | -------------------- | ------- |
| `width`    | `Responsive<string>` | —       |
| `minWidth` | `Responsive<string>` | —       |
| `maxWidth` | `Responsive<string>` | —       |

### Height

Height props accept any valid [CSS height value](https://developer.mozilla.org/en-US/docs/Web/CSS/height).

```jsx
<>

<Box height="100px" />

<Box height={{
    md: '100vh',
    xl: '600px'
  }} />

</>;
```

| Prop        | Type                 | Default |
| ----------- | -------------------- | ------- |
| `height`    | `Responsive<string>` | —       |
| `minHeight` | `Responsive<string>` | —       |
| `maxHeight` | `Responsive<string>` | —       |

### Positioning

Positioning props can change how the element is placed relative to the normal flow of the document. As usual, the corresponding CSS values are accepted for each property, and the [space scale steps](/themes/docs/theme/spacing) can be used for the offset values.

```jsx
<>

<Box position="relative" />

<Box position={{
    initial: "relative",
    lg: "sticky"
  }} />



<Box inset="4" />

<Box inset={{
    initial: "0",
    xl: "auto"
  }} />



<Box left="4" />

<Box left={{
    initial: "0",
    xl: "auto"
  }} />

</>;
```

| Prop       | Type                         | Default |
| ---------- | ---------------------------- | ------- |
| `position` | `Responsive<enum>`           | —       |
| `inset`    | `Responsive<enum \| string>` | —       |
| `top`      | `Responsive<enum \| string>` | —       |
| `right`    | `Responsive<enum \| string>` | —       |
| `bottom`   | `Responsive<enum \| string>` | —       |
| `left`     | `Responsive<enum \| string>` | —       |

### Flex children

Each layout component has props used to control the style when it is a child of a flex container.

```jsx
<>

<Box flexBasis="100%" />

<Box flexShrink="0" />

<Box flexGrow={{
    initial: "0",
    lg: "1"
  }} />

</>;
```

| Prop         | Type                         | Default |
| ------------ | ---------------------------- | ------- |
| `flexBasis`  | `Responsive<string>`         | —       |
| `flexShrink` | `Responsive<enum \| string>` | —       |
| `flexGrow`   | `Responsive<enum \| string>` | —       |

### Grid children

Each layout component has props used to control the style when it is a child of a grid container.

```jsx
<>

<Box gridArea="header" />



<Box gridColumn="1 / 3" />

<Box gridColumnStart="2" />

<Box gridColumnEnd={{
    initial: "-1",
    md: "3",
    lg: "auto"
  }} />



<Box gridRow="1 / 3" />

<Box gridRowStart="2" />

<Box gridRowEnd={{
    initial: "-1",
    md: "3",
    lg: "auto"
  }} />

</>;
```

| Prop              | Type                 | Default |
| ----------------- | -------------------- | ------- |
| `gridArea`        | `Responsive<string>` | —       |
| `gridColumn`      | `Responsive<string>` | —       |
| `gridColumnStart` | `Responsive<string>` | —       |
| `gridColumnEnd`   | `Responsive<string>` | —       |
| `gridRow`         | `Responsive<string>` | —       |
| `gridRowStart`    | `Responsive<string>` | —       |
| `gridRowEnd`      | `Responsive<string>` | —       |

## Margin props

Margin props are available on most components in order to provide spacing around the elements. They are not exclusive to layout components.

Margin props can access the [space scale steps](/themes/docs/theme/spacing) or accept any valid [CSS margin value](https://developer.mozilla.org/en-US/docs/Web/CSS/margin)

```jsx
<>

<Button m="4" />

<Button m="100px" />

<Button m={{
    sm: '6',
    lg: '9'
  }} />

</>;
```

| Prop | Type                         | Default |
| ---- | ---------------------------- | ------- |
| `m`  | `Responsive<enum \| string>` | —       |
| `mx` | `Responsive<enum \| string>` | —       |
| `my` | `Responsive<enum \| string>` | —       |
| `mt` | `Responsive<enum \| string>` | —       |
| `mr` | `Responsive<enum \| string>` | —       |
| `mb` | `Responsive<enum \| string>` | —       |
| `ml` | `Responsive<enum \| string>` | —       |

The margin props may be unavailable on components that don’t render a HTML node or rely on their Root part for layout.

## Standalone usage

If needed, it’s possible to use _just_ the layout component from Radix Themes. Just make sure that JavaScript tree-shaking works on your side, and import the CSS that powers the layout styles:

```jsx
import "@radix-solid/themes/layout.css";
```

You’ll still have to wrap your app with `Theme` to provide the space scale and scaling factor settings.
