Veil UI
Components

Stack

Arranges children in a row or column with consistent gaps.

Installation

$ npx veil-ui@latest add stack

Usage

import { Stack } from "@/components/ui/stack";

<Stack gap="sm">
  <Item />
  <Item />
</Stack>;

Examples

Vertical

Design tokens
Components
Blocks

Horizontal

v0.1.0MIT25 components

Toolbar

Deployment

API reference

PropTypeDefaultDescription
direction"row" | "column""column"Main axis of the flex container.
gap"none" | "xs" | "sm" | "md" | "lg" | "xl""md"Space between children: 0, 4, 8, 16, 24 or 32px.
align"start" | "center" | "end" | "stretch" | "baseline""stretch"Cross-axis alignment.
justify"start" | "center" | "end" | "between" | "around""start"Main-axis distribution.
wrapbooleanfalseAllow children to wrap onto multiple lines.
...propsReact.ComponentProps<"div">—All native div attributes.

Accessibility

  • Presentational flex wrapper; it adds no ARIA roles or landmarks.
  • direction, gap, align and justify map to static classes, so they work with Tailwind's compiler and never rely on runtime string interpolation.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add stack --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { computed } from "vue";

import { cn } from "@/lib/utils";

const gaps = {
  none: "gap-0",
  xs: "gap-1",
  sm: "gap-2",
  md: "gap-4",
  lg: "gap-6",
  xl: "gap-8",
} as const;

const alignments = {
  start: "items-start",
  center: "items-center",
  end: "items-end",
  stretch: "items-stretch",
  baseline: "items-baseline",
} as const;

const justifications = {
  start: "justify-start",
  center: "justify-center",
  end: "justify-end",
  between: "justify-between",
  around: "justify-around",
} as const;

const props = withDefaults(
  defineProps<{
    direction?: "row" | "column";
    gap?: keyof typeof gaps;
    align?: keyof typeof alignments;
    justify?: keyof typeof justifications;
    wrap?: boolean;
    class?: string;
  }>(),
  {
    direction: "column",
    gap: "md",
    align: "stretch",
    justify: "start",
    wrap: false,
  },
);

const classes = computed(() =>
  cn(
    "flex",
    props.direction === "row" ? "flex-row" : "flex-col",
    gaps[props.gap],
    alignments[props.align],
    justifications[props.justify],
    props.wrap && "flex-wrap",
    props.class,
  ),
);
</script>

<template>
  <div data-slot="stack" :data-direction="direction" :class="classes">
    <slot />
  </div>
</template>

On this page