Layout
Stack
Lays its children out top to bottom with an even gap. It is layout only: it replaces the flex flex-col gap-4 an agent would otherwise write by hand.
Install
Once per app, with Tailwind CSS v4 and an @/* path alias (Ouro HX is built on Base UI, so --base base; skip -t in an existing app):
npx shadcn@latest init --base base --preset nova --yes --no-monoreponpx shadcn@latest add ourostack/ouro-ui/ouro-base#v1.2.13Then the component. From v0.8.0 it installs only the helpers it imports and never touches your stylesheet (Installing):
npx shadcn@latest add ourostack/ouro-ui/stack#v1.2.13Or, with the @ouro namespace set up:
npx shadcn@latest add @ouro/ouro-base @ouro/stackIts tests, stories and Playwright spec are optional. They need Vitest 4.1.11 or later, and from v0.8.0 never change a version your app has (Testing):
npx shadcn@latest add ourostack/ouro-ui/stack#v1.2.13 ourostack/ouro-ui/stack-tests#v1.2.13import { Stack } from "@/components/ouro/stack/stack";Paths use shadcn's default @/ alias; the CLI rewrites them to yours.
Example
<Stack gap="sm">
<Heading level={2}>Ingredients</Heading>
<Text>Two pounds of short ribs.</Text>
</Stack>
<Stack as="ul" gap="xs">{items.map((item) => <li key={item.id}>{item.name}</li>)}</Stack>Use instead when
- Use
Rowinstead for a horizontal layout,Cardwhen the group needs a surface, andItemGroupfor a list of rows with media, titles and actions.
Props
Type: StackProps.
align- Type:
"start" | "center" | "end" | "stretch" - Default:
"stretch" - Where the children sit across the Stack.
stretchmakes each child full width. as- Type:
"form" | "div" | "aside" | "fieldset" | "footer" | "header" | "main" | "nav" | "ol" | "section" | "ul" - Default:
"div" - The element to render. A
ulorolloses its bullets and indent, afieldsetits border. children- Type:
ReactNode - The children, laid out top to bottom.
className- Type:
string - Layout only: margins, width, grid placement (
mt-4,max-w-md). Appearance classes warn in development: a Stack has no look; useCardfor a surface. So do the flex classes the props own: usegap,alignandjustify, notgap-*,items-*orjustify-*, and<Row>, notflex-row. gap- Type:
"sm" | "md" | "lg" | "xl" | "xs" | "none" - Default:
"md" - Space between the children:
xs4px,sm8px,md16px,lg24px,xl32px. justify- Type:
"start" | "center" | "end" | "between" - Default:
"start" - Where the children sit down the Stack, when it is taller than they are.
ref- Type:
Ref<HTMLElement> - Reaches the rendered element.
Native attributes
Also accepts the attributes in React's HTMLAttributes (id, aria-*, event handlers), passed to the rendered element, except those named on this page.
Don't use
These are not props. Passing one fails the type check with the fix in the error, and in development a console message names the fix.
alignItems: Not a prop. Ouro UI usesalign:<Stack align="center">.direction: Not a prop. Stack is vertical; for a horizontal layout use<Row>.justifyContent: Not a prop. Ouro UI usesjustify:<Stack justify="between">.spacing: Not a prop. Ouro UI usesgap:<Stack gap="sm">.
className is for layout only
Pass margins, width and grid placement (mt-4, w-full, col-span-2). Your classes always win over Ouro UI's: Stack merges className last with cn (tailwind-merge), so a class that conflicts with its own replaces it.layout-classes
Appearance comes from props, not classes. In development, a class that sets appearance logs one warning per component instance, naming the prop to use instead. A class sets appearance when, after its variants (hover:, sm:) and any ! are removed, it starts with bg-, text-, border-, rounded-, shadow-, font-, ring-, from-, via-, to-, fill- or stroke-, or is border, rounded, shadow or ring, or has a dark: variant. Text wrapping, overflow and table layout classes (text-wrap, text-ellipsis, border-collapse) are layout and do not warn.
Alignment classes (text-center) warn too: use the align prop.
Claim sources
- layout-classes: test:registry/ouro/components/ouro/stack/stack.test.tsx::Stack > passes HTML attributes and a ref through, and lets layout classes win
verify:testExists(registry/ouro/components/ouro/stack/stack.test.tsx::Stack > passes HTML attributes and a ref through, and lets layout classes win)