All components
Stack
Flex layout primitives (Stack, VStack, HStack) with spacing-token gaps, alignment, justification, and wrap controls.
Overview
Metrics
Logs
VStack item 1
VStack item 2
12345678910111213141516171819import { Stack, VStack, HStack } from "#components/ui/ark-ui/stack.tsx";
export function Example() { return ( <VStack gap="4"> <HStack gap="2" justify="between"> <span>Release v4.2</span> <span>Ready</span> </HStack>
{/* polymorphic composition via asChild */} <Stack direction="row" gap="3" wrap="wrap"> <span>Tokens</span> <span>Recipes</span> <span>Blocks</span> </Stack> </VStack> );}HStack & VStack
Use HStack for horizontal toolbars and VStack for vertical flows with token-backed spacing.
HStack (justify="between")
Left
Center
Right
Stack (wrap="wrap")
Design
Engineering
Product
Security
Install
1npx stylexblocks add stackSource
components/ui/ark-ui/stack.tsx
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697import * as stylex from "@stylexjs/stylex";import { createComponent } from "#lib/ark-ui/create-component.tsx";import { defineRecipe } from "#lib/recipe-props.ts";import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";
const stackStyles = stylex.create({ base: { display: "flex", minWidth: 0, },});
const stackDirections = stylex.create({ column: { flexDirection: "column" }, row: { flexDirection: "row" }, columnReverse: { flexDirection: "column-reverse" }, rowReverse: { flexDirection: "row-reverse" },});
const stackGaps = stylex.create({ "0": { gap: 0 }, "0.5": { gap: spacing._0_5 }, "1": { gap: spacing._1 }, "1.5": { gap: spacing._1_5 }, "2": { gap: spacing._2 }, "2.5": { gap: spacing._2_5 }, "3": { gap: spacing._3 }, "4": { gap: spacing._4 }, "5": { gap: spacing._5 }, "6": { gap: spacing._6 }, "8": { gap: spacing._8 }, "10": { gap: spacing._10 }, "12": { gap: spacing._12 },});
const stackAligns = stylex.create({ start: { alignItems: "flex-start" }, center: { alignItems: "center" }, end: { alignItems: "flex-end" }, stretch: { alignItems: "stretch" }, baseline: { alignItems: "baseline" },});
const stackJustifies = stylex.create({ start: { justifyContent: "flex-start" }, center: { justifyContent: "center" }, end: { justifyContent: "flex-end" }, between: { justifyContent: "space-between" }, around: { justifyContent: "space-around" }, evenly: { justifyContent: "space-evenly" },});
const stackWraps = stylex.create({ nowrap: { flexWrap: "nowrap" }, wrap: { flexWrap: "wrap" }, wrapReverse: { flexWrap: "wrap-reverse" },});
/** * Stack — flex layout primitive with spacing-token `gap`, alignment, * justification, wrapping, and direction axes. Composition via `asChild`. */const stackRecipe = defineRecipe({ styles: stackStyles, axes: { direction: stackDirections, gap: stackGaps, align: stackAligns, justify: stackJustifies, wrap: stackWraps, }, defaultVariants: { direction: "column", gap: "3", align: "stretch", justify: "start", wrap: "nowrap", },});
export const Stack = createComponent("div", stackRecipe, "Stack");export type StackProps = React.ComponentProps<typeof Stack>;
/** Vertical stack (`direction="column"`, `align="stretch"`). */export function VStack(props: Omit<StackProps, "direction">) { return <Stack direction="column" align="stretch" {...props} />;}VStack.displayName = "VStack";export type VStackProps = React.ComponentProps<typeof VStack>;
/** Horizontal stack (`direction="row"`, `align="center"`). */export function HStack(props: Omit<StackProps, "direction">) { return <Stack direction="row" align="center" {...props} />;}HStack.displayName = "HStack";export type HStackProps = React.ComponentProps<typeof HStack>;