---
title: "Stack 컴포넌트 — zenit Zig UI"
description: "자주 쓰는 가로, 세로 배치.gap, align, justify, wrap이 기본 box 레이아웃과 같은 좌표 규칙을 사용합니다."
url: https://zenit.z.express/ko/components/stack
language: ko
alternate_en: https://zenit.z.express/components/stack.md
alternate_zh: https://zenit.z.express/zh/components/stack.md
alternate_es: https://zenit.z.express/es/components/stack.md
alternate_ja: https://zenit.z.express/ja/components/stack.md
alternate_fr: https://zenit.z.express/fr/components/stack.md
alternate_de: https://zenit.z.express/de/components/stack.md
project: zenit v0.1.0-alpha (Zig 0.15.2, macOS)
source: https://github.com/version-next/zenit
---

# Stack

`ui.widgets.HStack / VStack`

자주 쓰는 가로, 세로 배치.

[Video](https://zenit.z.express/media/stories/stack.mp4?v=f9618b3adf)

**BEHAVIOR CONTRACT**

gap, align, justify, wrap이 기본 box 레이아웃과 같은 좌표 규칙을 사용합니다.

**RECORDED INTERACTION**

가로, 세로, 중첩 Stack을 보여 줍니다.

`examples/storybook/stories.zig:1894`

```zig
// ── Stack (VStack / HStack) ──
pub fn buildStack(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 16);
    try c.appendChild(a, try label(cx, "HStack gap=8"));
    const h = try W.HStack(.{ .gap = 8 }).mount(scope, cx);
    inline for (.{ "A", "B", "C" }) |t| {
        try h.appendChild(a, try W.Button(.{ .label = t, .variant = .secondary }).mount(scope, cx));
    }
    try c.appendChild(a, h);
    try c.appendChild(a, try label(cx, "VStack gap=8"));
    const v = try W.VStack(.{ .gap = 8 }).mount(scope, cx);
    inline for (.{ "First", "Second", "Third" }) |t| {
        try v.appendChild(a, try W.Tag(.{ .text = t }).mount(scope, cx));
    }
    try c.appendChild(a, v);
    return c;
}
```

[GitHub에서 소스 보기examples/storybook/stories.zig:1894](https://github.com/version-next/zenit/blob/HEAD/examples/storybook/stories.zig#L1894)

Storybook에 있는 이 story의 원본 코드입니다(zenit 5f9add5+wip 2026-09-30). `W`는 `ui.widgets`이며, `col` / `row` / `label`은 Storybook 내부의 작은 레이아웃 헬퍼입니다.

### HStackProps

`ui.widgets.HStack`

[src/ui/components/stack/mod.zig:110](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/stack/mod.zig#L110)

```zig
fn HStack(props: HStackProps) HStackBuilder
```

| 필드 | 타입 | 기본값 | 설명 |
| --- | --- | --- | --- |
| `gap` | `f32` | `0` | 间距 |
| `justify` | `Justify` | `.start` | 主轴对齐 |
| `align_items` | `Alignment` | `.center` | 交叉轴对齐 |
| `width` | `?f32` | `null` | 宽度 |
| `height` | `?f32` | `null` | 高度 |
| `padding` | `?Padding` | `null` | 内边距 |
| `background` | `?Color` | `null` | 背景色 |
| `reverse` | `bool` | `false` | 反向 |
| `wrap` | `bool` | `false` | 换行 |

### VStackProps

`ui.widgets.VStack`

[src/ui/components/stack/mod.zig:24](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/stack/mod.zig#L24)

```zig
fn VStack(props: VStackProps) VStackBuilder
```

| 필드 | 타입 | 기본값 | 설명 |
| --- | --- | --- | --- |
| `gap` | `f32` | `0` | 间距 |
| `justify` | `Justify` | `.start` | 主轴对齐 |
| `align_items` | `Alignment` | `.stretch` | 交叉轴对齐 |
| `width` | `?f32` | `null` | 宽度 |
| `height` | `?f32` | `null` | 高度 |
| `padding` | `?Padding` | `null` | 内边距 |
| `background` | `?Color` | `null` | 背景色 |
| `reverse` | `bool` | `false` | 反向 |

### \*Node

`ui.widgets.HStack`

mount는 `*Node`을(를) 직접 반환합니다. 부모 노드에 append하면 됩니다.

### \*Node

`ui.widgets.VStack`

mount는 `*Node`을(를) 직접 반환합니다. 부모 노드에 append하면 됩니다.
