---
title: ZStack
description: "`ZStack` is used to stack child elements in depth."
links:
- source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/stack
- storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-stack--depth
---
```tsx
{["info", "success", "warning", "error"].map((bg, index) => (
Box
))}
```
## Usage
```tsx
import { ZStack } from "@yamada-ui/react"
```
```tsx
import { ZStack } from "@/components/ui"
```
```tsx
import { ZStack } from "@workspaces/ui"
```
```tsx
```
### Changing Direction
To change the direction, set `direction` to `"start"`, `"end-end"`, etc.
```tsx
{["info", "success", "warning", "error"].map((bg, index) => (
Box
))}
```
### Reversing Direction
To reverse the direction, set `reverse` to `true`.
```tsx
{["info", "success", "warning", "error"].map((bg, index) => (
Box
))}
```
## Props
| Prop | Default | Type | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
| `direction` | `"end"` | `Direction` | Stack in the specified direction. |
| `fit` | `true` | `boolean` | If `true`, calculate the `width` and `height` of the element and assign container. |
| `reverse` | `false` | `boolean` | If `true`, reverse direction. |
| `startIndex` | `0` | `number` | If set the stack will start from the given index. |