Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

Layout -- system architecture plan and WebStack (#11)

Cindy Zhang705951d3477f
diff --git a/.context/explorations/stylex-patterns.md b/.context/explorations/stylex-patterns.md
index 3299337e55..65a4ddcf85 100644
--- a/.context/explorations/stylex-patterns.md
+++ b/.context/explorations/stylex-patterns.md
@@ -2,6 +2,72 @@
Notes on StyleX usage patterns discovered while building XDS components.
+## The `xstyle` Prop Pattern
+
+When components need configurable styles, use the `xstyle` prop with `StyleXStyles` type. This ensures consumers use StyleX instead of inline styles, maintaining compile-time optimization and consistency.
+
+### Implementation
+
+```tsx
+import type { StyleXStyles } from '@stylexjs/stylex';
+
+export interface MyComponentProps extends Omit<HTMLAttributes<HTMLElement>, 'style' | 'className'> {
+ // Component-specific props...
+
+ /** StyleX styles to apply to the component. */
+ xstyle?: StyleXStyles;
+
+ children?: ReactNode;
+}
+
+export const MyComponent = forwardRef<HTMLElement, MyComponentProps>(
+ function MyComponent({ xstyle, children, ...props }, ref) {
+ const stylexProps = stylex.props(styles.base, xstyle);
+
+ return (
+ <div ref={ref} {...stylexProps} {...props}>
+ {children}
+ </div>
+ );
+ }
+);
+```
+
+### Key Points
+
+1. **Omit `style` and `className`**: Use `Omit<HTMLAttributes<HTMLElement>, 'style' | 'className'>` to prevent inline styles and ensure StyleX usage.
+
+2. **Merge styles correctly**: Pass `xstyle` as the last argument to `stylex.props()` so consumer styles can override component defaults.
+
+3. **Constrained vs. freeform styles**:
+ - **Higher-level components** (e.g., Button, Card): Prefer constrained APIs with specific props (`variant`, `size`) over open `xstyle`. This enforces design consistency.
+ - **Primitive/layout components** (e.g., Stack, Box): It's acceptable to allow freeform `xstyle` since these are building blocks that need flexibility.
+
+### Usage Example
+
+```tsx
+import * as stylex from '@stylexjs/stylex';
+import { colorTokens } from '@xds/core';
+
+const customStyles = stylex.create({
+ highlight: {
+ backgroundColor: colorTokens.wash,
+ borderRadius: radiusTokens.element,
+ },
+});
+
+// Consumer usage
+<XDSHStack gap="space2" xstyle={customStyles.highlight}>
+ <Item />
+ <Item />
+</XDSHStack>
+
+// Multiple styles via array
+<XDSVStack xstyle={[styles.container, styles.padded]}>
+ <Content />
+</XDSVStack>
+```
+
## Compile-Time Requirement
StyleX requires all styles to be compiled at build time via the Babel plugin. You cannot use `stylex.create()` at runtime (e.g., in Storybook's preview.tsx).
diff --git a/.context/proposals/layout-system.md b/.context/proposals/layout-system.md
new file mode 100644
index 0000000000..d6b2759833
--- /dev/null
+++ b/.context/proposals/layout-system.md
@@ -0,0 +1,442 @@
+# XDS Layout System Proposal
+
+*Proposal — January 2026*
+
+## Overview
+
+A composable layout system for building consistent, structured layouts with zero styling customization. The system follows a container/content separation pattern with intelligent context-aware behavior.
+
+### Design Principles
+
+1. **Zero styling build** — No `xstyle` customization on layout components
+2. **Context-aware defaults** — Components detect their environment and self-adjust
+3. **LLM-friendly API** — Clear, discoverable props with self-documenting names
+4. **Composition over configuration** — Simple primitives that combine into complex patterns
+
+---
+
+## Component Hierarchy
+
+```
+┌─────────────────────────────────────────────────────────────────┐
+│ HIGHER-ORDER PATTERNS │
+│ Card, HoverCard, Popover, Modal │
+│ (Compose layouts into complete UI patterns) │
+├─────────────────────────────────────────────────────────────────┤
+│ LAYOUT STRUCTURE │
+│ XDSLayoutContainer + XDSLayout │
+│ (Container appearance + section arrangement) │
+├─────────────────────────────────────────────────────────────────┤
+│ CONTENT AREAS │
+│ XDSLayoutHeader, XDSLayoutFooter, XDSLayoutContent, │
+│ XDSLayoutPanel │
+│ (Regions that hold content) │
+├─────────────────────────────────────────────────────────────────┤
+│ LAYOUT PRIMITIVES │
+│ HStack, VStack, SplitPane, Grid, Divider │
+│ (Arrangement and spacing tools) │
+└─────────────────────────────────────────────────────────────────┘
+```
+
+---
+
+## Core Components
+
+### XDSLayoutContainer
+
+Outer container that sets visual appearance and padding context.
+
+| Prop | Type | Description |
+|------|------|-------------|
+| `variant` | `'page' \| 'card' \| 'modal' \| 'section' \| 'hovercard' \| 'popover'` | Visual variant determining elevation and padding |
+| `children` | `React.Node` | Must be an `XDSLayout` component |
+
+### XDSLayout
+
+Arranges sections using named slots. Does not handle visual appearance — that's the Container's job.
+
+```
+┌─────────────────────────────────────────┐
+│ header │
+├──────┬─────────────────────────┬────────┤
+│start │ content │ end │
+├──────┴─────────────────────────┴────────┤
+│ footer │
+└─────────────────────────────────────────┘
+```
+
+| Prop | Type | Description |
+|------|------|-------------|
+| `header` | `React.Node` | Header slot |
+| `footer` | `React.Node` | Footer slot |
+| `start` | `React.Node` | Start panel slot (left in LTR) |
+| `end` | `React.Node` | End panel slot (right in LTR) |
+| `content` | `React.Node` | Main content slot |
+| `height` | `'fill' \| 'auto'` | `fill`: layout fills container, content scrolls. `auto`: layout grows with content |
+| `isFullBleed` | `boolean` | Removes padding at layout's outer edges |
+
+### Content Areas
+
+`XDSLayoutHeader`, `XDSLayoutFooter`, `XDSLayoutContent`, `XDSLayoutPanel`
+
+| Prop | Type | Description |
+|------|------|-------------|
+| `children` | `React.Node` | Area content |
+| `hasDivider` | `boolean` | Adds themed border (position auto-detected) |
+| `isFullBleed` | `boolean` | Removes this area's internal padding |
+| `role` | `string` | ARIA landmark role (e.g., `'banner'`, `'main'`, `'navigation'`, `'contentinfo'`) |
+
+---
+
+## Basic Usage
+
+```jsx
+<XDSLayoutContainer variant="card">
+ <XDSLayout
+ header={<XDSLayoutHeader hasDivider>Title</XDSLayoutHeader>}
+ content={<XDSLayoutContent>Body</XDSLayoutContent>}
+ footer={<XDSLayoutFooter>Actions</XDSLayoutFooter>}
+ />
+</XDSLayoutContainer>
+```
+
+### With Sidebar
+
+```jsx
+<XDSLayoutContainer variant="card">
+ <XDSLayout
+ header={<XDSLayoutHeader hasDivider>Dashboard</XDSLayoutHeader>}
+ start={<XDSLayoutPanel hasDivider><XDSList items={navItems} /></XDSLayoutPanel>}
+ content={<XDSLayoutContent>Main content</XDSLayoutContent>}
+ />
+</XDSLayoutContainer>
+```
+
+### Full Bleed Content
+
+```jsx
+<XDSLayoutContainer variant="card">
+ <XDSLayout
+ header={<XDSLayoutHeader>Users</XDSLayoutHeader>}
+ content={
+ <XDSLayoutContent isFullBleed>
+ <XDSTable ... />
+ </XDSLayoutContent>
+ }
+ />
+</XDSLayoutContainer>
+```
+
+---
+
+## Why Separate Container + Layout
+
+Separation enables **reusable layout structures** across different contexts:
+
+```jsx
+// Define layout structure once
+const NavigationLayout = ({items, content}) => (
+ <XDSLayout
+ start={<XDSLayoutPanel><XDSList items={items} /></XDSLayoutPanel>}
+ content={<XDSLayoutContent>{content}</XDSLayoutContent>}
+ />
+);
+
+// Desktop: inside a popover menu
+<XDSLayoutContainer variant="popover">
+ <NavigationLayout items={navItems} content={<Details />} />
+</XDSLayoutContainer>
+
+// Mobile: full page layout
+<XDSLayoutContainer variant="page">
+ <NavigationLayout items={navItems} content={<Details />} />
+</XDSLayoutContainer>
+```
+
+**Key benefit:** Author the layout once, adapt the container for responsive or contextual needs.
+
+### LLM Considerations
+
+The two-component pattern requires LLMs to remember the wrapper. Mitigations:
+
+1. **Higher-order patterns are primary** — Most code uses `XDSCard`, `XDSModal`, etc.
+2. **JSDoc on XDSLayout** — States "must be wrapped in XDSLayoutContainer"
+3. **Examples emphasize the pattern** — All raw Layout examples show the Container wrapper
+4. **TypeScript context check** — XDSLayout can warn if not inside a Container
+
+---
+
+## Full Bleed Behavior
+
+`isFullBleed` exists at two levels with different scopes:
+
+| Level | Effect |
+|-------|--------|
+| `XDSLayout isFullBleed` | Layout touches container edges (outer spacing removed) |
+| `XDSLayoutContent isFullBleed` | Content area has no internal padding |
+
+These are independent — use both when needed.
+
+```
+Layout isFullBleed=false Layout isFullBleed=true
+┌────────────────────────┐ ┌────────────────────────┐
+│ ┌────────────────┐ │ │┌──────────────────────┐│
+│ │ content │ │ → ││ content ││
+│ └────────────────┘ │ │└──────────────────────┘│
+└────────────────────────┘ └────────────────────────┘
+ outer padding no outer padding
+```
+
+---
+
+## Padding via Variants
+
+Padding is controlled entirely through container variants. Each variant defines spacing as CSS variables.
+
+| Variant | Outer Spacing | Inner Spacing | Use Case |
+|---------|---------------|---------------|----------|
+| `page` | 16px | 16px | Full page layouts |
+| `card` | 16px | 16px | Elevated content containers |
+| `modal` | 16px | 16px | Dialog overlays |
+| `section` | 16px | 16px | Content sections within a page |
+| `hovercard` | 12px | 12px | Hover-triggered content |
+| `popover` | 12px | 12px | Click-triggered overlays |
+
+### How It Works
+
+1. `XDSLayoutContainer` sets CSS variables based on `variant`
+2. `XDSLayout` reads outer spacing variable
+3. Content areas read inner spacing variable
+4. `isFullBleed` overrides these to `0`
+
+```css
+/* card, section, page, modal */
+--xds-layout-outer-spacing: 16px;
+--xds-layout-inner-spacing: 16px;
+
+/* hovercard, popover */
+--xds-layout-outer-spacing: 12px;
+--xds-layout-inner-spacing: 12px;
+```
+
+### Theming
+
+Since spacing is controlled via CSS variables, themes can override these values. A theme with denser spacing might use:
+
+```css
+/* Dense theme overrides */
+--xds-layout-outer-spacing: 12px;
+--xds-layout-inner-spacing: 12px;
+```
+
+This allows the same component code to adapt to different visual densities across themes.
+
+---
+
+## Auto-Adjusting Components
+
+Components inside layout areas detect context and self-adjust. No explicit props needed.
+
+| Component | Behavior |
+|-----------|----------|
+| `XDSList` | Applies spacing correction automatically |
+| `XDSScrollableArea` | Pushes scrollbar to container edge |
+| `XDSTable` | Extends edge-to-edge within container |
+
+```jsx
+// Just works — no props needed
+<XDSLayoutPanel>
+ <XDSList items={navItems} />
+</XDSLayoutPanel>
+```
+
+---
+
+## Dividers
+
+`hasDivider` on content areas auto-places the divider on the correct edge:
+
+| Component | Divider Position |
+|-----------|------------------|
+| Header | Bottom edge |
+| Footer | Top edge |
+| Panel (start) | End edge |
+| Panel (end) | Start edge |
+
+When `hasDivider` is false, spacing collapse is applied automatically for seamless visual flow.
+
+---
+
+## Scroll Behavior
+
+| `height` | Behavior |
+|----------|----------|
+| `"fill"` (default) | Layout fills container, content scrolls internally |
+| `"auto"` | Layout grows with content, container/page scrolls |
+
+---
+
+## Higher-Order Patterns
+
+Pre-composed patterns for common use cases. These are the primary API for most users.
+
+| Pattern | Use Case |
+|---------|----------|
+| `XDSCard` | Elevated content container |
+| `XDSModal` | Dialog overlay |
+| `XDSPopover` | Click-triggered overlay |
+| `XDSHoverCard` | Hover-triggered content |
+
+Each pattern internally composes `XDSLayoutContainer` + `XDSLayout`:
+
+```jsx
+// XDSCard usage (named slots)
+<XDSCard
+ header={<XDSCard.Header>Title</XDSCard.Header>}
+ content={<XDSCard.Content>Body</XDSCard.Content>}
+ footer={<XDSCard.Footer>Actions</XDSCard.Footer>}
+/>
+
+// XDSModal usage
+<XDSModal
+ isOpen={open}
+ onClose={close}
+ header={<XDSModal.Header>Confirm</XDSModal.Header>}
+ content={<XDSModal.Content>Are you sure?</XDSModal.Content>}
+ footer={<XDSModal.Footer>...</XDSModal.Footer>}
+/>
+```
+
+---
+
+## Additional Components (API TBD)
+
+| Component | Description |
+|-----------|-------------|
+| `XDSSplitPane` | Resizable panels. Horizontal and vertical orientations. |
+| `XDSGrid` | Responsive grid layout. |
+| `XDSHStack` | Horizontal stack with gap. |
+| `XDSVStack` | Vertical stack with gap. |
+| `XDSDivider` | Themed divider with `isFullBleed` support. |
+
+---
+
+## Component Summary
+
+| Component | Role | Key Props |
+|-----------|------|-----------|
+| `XDSLayoutContainer` | Visual appearance + padding context | `variant` |
+| `XDSLayout` | Section arrangement | `header`, `footer`, `start`, `end`, `content`, `height`, `isFullBleed` |
+| `XDSLayoutHeader` | Header area | `hasDivider`, `isFullBleed` |
+| `XDSLayoutFooter` | Footer area | `hasDivider`, `isFullBleed` |
+| `XDSLayoutContent` | Main content area | `isFullBleed` |
+| `XDSLayoutPanel` | Side panel | `hasDivider`, `isFullBleed` |
+
+---
+
+## LLM Pattern Design
+
+The API is designed for LLM pattern retention and consistency:
+
+### Naming Symmetry
+
+Slot names match component names, creating strong associations:
+
+| Slot | Component |
+|------|-----------|
+| `header=` | `<XDSLayoutHeader>` |
+| `footer=` | `<XDSLayoutFooter>` |
+| `content=` | `<XDSLayoutContent>` |
+| `start=` / `end=` | `<XDSLayoutPanel>` |
+
+LLMs can infer: "the `header` slot takes the `Header` component."
+
+### Typed Slots
+
+Slot types reinforce what goes where:
+
+```typescript
+header?: React.ReactElement<XDSLayoutHeaderProps>;
+footer?: React.ReactElement<XDSLayoutFooterProps>;
+content?: React.ReactElement<XDSLayoutContentProps>;
+start?: React.ReactElement<XDSLayoutPanelProps>;
+end?: React.ReactElement<XDSLayoutPanelProps>;
+```
+
+### Canonical Examples in JSDoc
+
+Every component includes a complete example in its JSDoc:
+
+```typescript
+/**
+ * Container for XDSLayout. Sets visual appearance and padding.
+ *
+ * @example
+ * <XDSLayoutContainer variant="card">
+ * <XDSLayout
+ * header={<XDSLayoutHeader>Title</XDSLayoutHeader>}
+ * content={<XDSLayoutContent>Body</XDSLayoutContent>}
+ * />
+ * </XDSLayoutContainer>
+ */
+```
+
+LLMs often pull from JSDoc examples directly.
+
+### Consistent Pattern Repetition
+
+All documentation examples follow the same structure:
+1. `XDSLayoutContainer` wraps `XDSLayout`
+2. Named slots receive matching components
+3. No alternative patterns shown
+
+This repetition builds strong pattern recognition.
+
+---
+
+## Open Questions
+
+1. **Nested layouts** — How do contexts compose when layouts are nested?
+2. **SplitPane/Grid** — Detailed API design
+3. **Animation** — Transition support for panels (collapse/expand)?
+
+---
+
+## RTL Support
+
+The `start`/`end` naming (rather than `left`/`right`) enables automatic RTL handling via CSS logical properties:
+
+| Direction | `start` panel | `end` panel |
+|-----------|---------------|-------------|
+| LTR | Left side | Right side |
+| RTL | Right side | Left side |
+
+Implementation uses logical CSS properties (`inset-inline-start`, `padding-inline-end`, etc.) so no additional props or configuration are needed. RTL layouts work automatically when `dir="rtl"` is set on a parent element.
+
+---
+
+## Accessibility
+
+Content areas support ARIA landmark roles via the `role` prop:
+
+| Component | Suggested Role | Renders As |
+|-----------|----------------|------------|
+| `XDSLayoutHeader` | `"banner"` | `<header>` or `<div role="banner">` |
+| `XDSLayoutFooter` | `"contentinfo"` | `<footer>` or `<div role="contentinfo">` |
+| `XDSLayoutContent` | `"main"` | `<main>` or `<div role="main">` |
+| `XDSLayoutPanel` | `"navigation"` / `"complementary"` | `<aside>` or `<nav>` |
+
+**Design decision:** Should content areas render semantic HTML elements by default, or require explicit `role` prop?
+
+- **Option A:** Default to semantic elements (`<header>`, `<main>`, etc.) based on component type
+- **Option B:** Default to `<div>`, require `role` prop for landmarks
+- **Option C:** Default to semantic elements, allow `as` prop to override
+
+Semantic defaults (Option A/C) provide better accessibility out-of-the-box but may cause issues with nested layouts (multiple `<main>` elements).
+
+---
+
+## Related Documentation
+
+- `xds-architecture.md` — Overall XDS architecture and theming
+- `zero-styling-architecture.md` — Zero styling philosophy
diff --git a/apps/storybook/.babelrc.cjs b/apps/storybook/.babelrc.cjs
index 13c7d68e46..6000183dbd 100644
--- a/apps/storybook/.babelrc.cjs
+++ b/apps/storybook/.babelrc.cjs
@@ -5,6 +5,10 @@
* @position Build config; used by Vite and PostCSS for transpilation
*/
+const path = require('path');
+
+const rootDir = path.join(__dirname, '../..');
+
module.exports = {
presets: [
['@babel/preset-react', { runtime: 'automatic' }],
@@ -14,13 +18,17 @@ module.exports = {
[
'@stylexjs/babel-plugin',
{
- dev: process.env.NODE_ENV === 'development',
- runtimeInjection: false,
+ dev: true,
+ runtimeInjection: true,
genConditionalClasses: true,
treeshakeCompensation: true,
+ aliases: {
+ '@xds/core/*': [path.join(rootDir, 'packages/core/src/*')],
+ '@xds/core': [path.join(rootDir, 'packages/core/src')],
+ },
unstable_moduleResolution: {
type: 'commonJS',
- rootDir: __dirname,
+ rootDir: rootDir,
},
},
],
diff --git a/apps/storybook/.storybook/preview.tsx b/apps/storybook/.storybook/preview.tsx
index b83be82f96..37332e2096 100644
--- a/apps/storybook/.storybook/preview.tsx
+++ b/apps/storybook/.storybook/preview.tsx
@@ -1,6 +1,8 @@
import type { Preview, Decorator } from '@storybook/react';
import * as React from 'react';
-import { Theme, defaultTheme, neutralTheme } from '@xds/core';
+import { Theme } from '@xds/core/theme/Theme';
+import { defaultTheme } from '@xds/core/theme/defaultTheme.stylex';
+import { neutralTheme } from '@xds/core/theme/neutralTheme.stylex';
/**
* Map of available themes
diff --git a/apps/storybook/stories/HStack.stories.tsx b/apps/storybook/stories/HStack.stories.tsx
new file mode 100644
index 0000000000..76fd15e8b4
--- /dev/null
+++ b/apps/storybook/stories/HStack.stories.tsx
@@ -0,0 +1,227 @@
+import type { Meta, StoryObj } from '@storybook/react';
+import * as stylex from '@stylexjs/stylex';
+import { XDSHStack } from '@xds/core/Layout';
+import {
+ colorTokens,
+ spacingTokens,
+ radiusTokens,
+ typographyTokens,
+} from '@xds/core/theme/tokens.stylex';
+
+const styles = stylex.create({
+ box: {
+ backgroundColor: colorTokens.blueBackground,
+ color: colorTokens.blueText,
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: colorTokens.blueBorder,
+ paddingBlock: spacingTokens.space4,
+ paddingInline: spacingTokens.space6,
+ borderRadius: radiusTokens.element,
+ fontWeight: 500,
+ },
+ boxAlt: {
+ backgroundColor: colorTokens.grayBackground,
+ color: colorTokens.grayText,
+ borderColor: colorTokens.grayBorder,
+ },
+ container: {
+ backgroundColor: colorTokens.wash,
+ },
+ containerHeight: {
+ height: 120,
+ },
+ containerHeightSmall: {
+ height: 80,
+ },
+ containerWidth: {
+ width: 300,
+ },
+ containerPadding: {
+ padding: spacingTokens.space2,
+ },
+ storyWrapper: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: spacingTokens.space6,
+ },
+ heading: {
+ margin: `0 0 ${spacingTokens.space2} 0`,
+ fontFamily: typographyTokens.fontFamilyBody,
+ },
+});
+
+// Demo box component for visibility
+const Box = ({ children, alt = false }: { children: React.ReactNode; alt?: boolean }) => (
+ <div {...stylex.props(styles.box, alt && styles.boxAlt)}>{children}</div>
+);
+
+const meta: Meta<typeof XDSHStack> = {
+ title: 'Layout/XDSHStack',
+ component: XDSHStack,
+ tags: ['autodocs'],
+ argTypes: {
+ gap: {
+ control: 'select',
+ options: ['space0', 'space0.5', 'space1', 'space2', 'space3', 'space4', 'space5', 'space6', 'space7'],
+ description: 'Spacing token for gap between items',
+ },
+ vAlign: {
+ control: 'select',
+ options: ['start', 'center', 'end', 'stretch'],
+ description: 'Vertical alignment of items',
+ },
+ wrap: {
+ control: 'select',
+ options: ['nowrap', 'wrap', 'wrap-reverse'],
+ description: 'Flex wrap behavior',
+ },
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof XDSHStack>;
+
+export const Default: Story = {
+ args: {
+ gap: 'space2',
+ children: null,
+ },
+ render: (args) => (
+ <XDSHStack {...args}>
+ <Box>Item 1</Box>
+ <Box>Item 2</Box>
+ <Box>Item 3</Box>
+ </XDSHStack>
+ ),
+};
+
+export const WithGap: Story = {
+ args: {
+ gap: 'space4',
+ },
+ render: (args) => (
+ <XDSHStack {...args}>
+ <Box>Item 1</Box>
+ <Box>Item 2</Box>
+ <Box>Item 3</Box>
+ </XDSHStack>
+ ),
+};
+
+export const VerticalAlignCenter: Story = {
+ args: {
+ gap: 'space4',
+ vAlign: 'center',
+ },
+ render: (args) => (
+ <XDSHStack {...args} xstyle={[styles.container, styles.containerHeight]}>
+ <Box>Short</Box>
+ <Box>
+ Tall
+ <br />
+ Item
+ </Box>
+ <Box>Short</Box>
+ </XDSHStack>
+ ),
+};
+
+export const VerticalAlignStart: Story = {
+ args: {
+ gap: 'space4',
+ vAlign: 'start',
+ },
+ render: (args) => (
+ <XDSHStack {...args} xstyle={[styles.container, styles.containerHeight]}>
+ <Box>Short</Box>
+ <Box>
+ Tall
+ <br />
+ Item
+ </Box>
+ <Box>Short</Box>
+ </XDSHStack>
+ ),
+};
+
+export const VerticalAlignEnd: Story = {
+ args: {
+ gap: 'space4',
+ vAlign: 'end',
+ },
+ render: (args) => (
+ <XDSHStack {...args} xstyle={[styles.container, styles.containerHeight]}>
+ <Box>Short</Box>
+ <Box>
+ Tall
+ <br />
+ Item
+ </Box>
+ <Box>Short</Box>
+ </XDSHStack>
+ ),
+};
+
+export const Wrapping: Story = {
+ args: {
+ gap: 'space2',
+ wrap: 'wrap',
+ },
+ render: (args) => (
+ <XDSHStack {...args} xstyle={[styles.container, styles.containerWidth, styles.containerPadding]}>
+ <Box>Item 1</Box>
+ <Box>Item 2</Box>
+ <Box>Item 3</Box>
+ <Box>Item 4</Box>
+ <Box>Item 5</Box>
+ </XDSHStack>
+ ),
+};
+
+export const AllAlignments: Story = {
+ render: () => (
+ <div {...stylex.props(styles.storyWrapper)}>
+ <div>
+ <h4 {...stylex.props(styles.heading)}>vAlign: start</h4>
+ <XDSHStack gap="space2" vAlign="start" xstyle={[styles.container, styles.containerHeightSmall]}>
+ <Box>A</Box>
+ <Box>
+ B<br />B
+ </Box>
+ <Box>C</Box>
+ </XDSHStack>
+ </div>
+ <div>
+ <h4 {...stylex.props(styles.heading)}>vAlign: center</h4>
+ <XDSHStack gap="space2" vAlign="center" xstyle={[styles.container, styles.containerHeightSmall]}>
+ <Box>A</Box>
+ <Box>
+ B<br />B
+ </Box>
+ <Box>C</Box>
+ </XDSHStack>
+ </div>
+ <div>
+ <h4 {...stylex.props(styles.heading)}>vAlign: end</h4>
+ <XDSHStack gap="space2" vAlign="end" xstyle={[styles.container, styles.containerHeightSmall]}>
+ <Box>A</Box>
+ <Box>
+ B<br />B
+ </Box>
+ <Box>C</Box>
+ </XDSHStack>
+ </div>
+ <div>
+ <h4 {...stylex.props(styles.heading)}>vAlign: stretch (default)</h4>
+ <XDSHStack gap="space2" vAlign="stretch" xstyle={[styles.container, styles.containerHeightSmall]}>
+ <Box>A</Box>
+ <Box>
+ B<br />B
+ </Box>
+ <Box>C</Box>
+ </XDSHStack>
+ </div>
+ </div>
+ ),
+};
diff --git a/apps/storybook/stories/StackItem.stories.tsx b/apps/storybook/stories/StackItem.stories.tsx
new file mode 100644
index 0000000000..f13a6df5df
--- /dev/null
+++ b/apps/storybook/stories/StackItem.stories.tsx
@@ -0,0 +1,231 @@
+import type { Meta, StoryObj } from '@storybook/react';
+import * as stylex from '@stylexjs/stylex';
+import { XDSHStack, XDSVStack, XDSStackItem } from '@xds/core/Layout';
+import {
+ colorTokens,
+ spacingTokens,
+ radiusTokens,
+ typographyTokens,
+} from '@xds/core/theme/tokens.stylex';
+
+const styles = stylex.create({
+ box: {
+ backgroundColor: colorTokens.blueBackground,
+ color: colorTokens.blueText,
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: colorTokens.blueBorder,
+ paddingBlock: spacingTokens.space4,
+ paddingInline: spacingTokens.space6,
+ borderRadius: radiusTokens.element,
+ fontWeight: 500,
+ height: '100%',
+ boxSizing: 'border-box',
+ },
+ boxAlt: {
+ backgroundColor: colorTokens.grayBackground,
+ color: colorTokens.grayText,
+ borderColor: colorTokens.grayBorder,
+ },
+ boxGreen: {
+ backgroundColor: colorTokens.greenBackground,
+ color: colorTokens.greenText,
+ borderColor: colorTokens.greenBorder,
+ },
+ boxPurple: {
+ backgroundColor: colorTokens.purpleBackground,
+ color: colorTokens.purpleText,
+ borderColor: colorTokens.purpleBorder,
+ },
+ boxOrange: {
+ backgroundColor: colorTokens.orangeBackground,
+ color: colorTokens.orangeText,
+ borderColor: colorTokens.orangeBorder,
+ },
+ container: {
+ backgroundColor: colorTokens.wash,
+ },
+ containerWidth: {
+ width: 500,
+ },
+ containerWidthLarge: {
+ width: 600,
+ },
+ containerHeight: {
+ height: 150,
+ },
+ containerHeightLarge: {
+ height: 200,
+ },
+ containerPadding: {
+ padding: spacingTokens.space2,
+ },
+ sidebarWidth: {
+ width: 150,
+ },
+ storyWrapper: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: spacingTokens.space6,
+ },
+ heading: {
+ margin: `0 0 ${spacingTokens.space2} 0`,
+ fontFamily: typographyTokens.fontFamilyBody,
+ },
+});
+
+// Demo box component for visibility
+const Box = ({ children, alt = false, green = false, purple = false, orange = false }: {
+ children: React.ReactNode;
+ alt?: boolean;
+ green?: boolean;
+ purple?: boolean;
+ orange?: boolean;
+}) => (
+ <div {...stylex.props(styles.box, alt && styles.boxAlt, green && styles.boxGreen, purple && styles.boxPurple, orange && styles.boxOrange)}>
+ {children}
+ </div>
+);
+
+const meta: Meta<typeof XDSStackItem> = {
+ title: 'Layout/XDSStackItem',
+ component: XDSStackItem,
+ tags: ['autodocs'],
+ argTypes: {
+ size: {
+ control: 'select',
+ options: ['static', 'fill'],
+ description: 'Size behavior within the stack',
+ },
+ crossAlignSelf: {
+ control: 'select',
+ options: ['start', 'center', 'end', 'stretch'],
+ description: 'Override cross-axis alignment for this item',
+ },
+ element: {
+ control: 'select',
+ options: ['div', 'section', 'article', 'aside', 'span'],
+ description: 'HTML element to render',
+ },
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof XDSStackItem>;
+
+export const Default: Story = {
+ args: {
+ size: 'static',
+ children: null,
+ },
+ render: (args) => (
+ <XDSHStack gap="space2" xstyle={[styles.container, styles.containerWidth, styles.containerPadding]}>
+ <XDSStackItem {...args}>
+ <Box>Stack Item</Box>
+ </XDSStackItem>
+ <Box alt>Other Item</Box>
+ </XDSHStack>
+ ),
+};
+
+export const FillSize: Story = {
+ render: () => (
+ <XDSHStack gap="space2" xstyle={[styles.container, styles.containerWidth, styles.containerPadding]}>
+ <XDSStackItem size="static">
+ <Box alt>Static</Box>
+ </XDSStackItem>
+ <XDSStackItem size="fill">
+ <Box>Fill (grows to fill remaining space)</Box>
+ </XDSStackItem>
+ <XDSStackItem size="static">
+ <Box alt>Static</Box>
+ </XDSStackItem>
+ </XDSHStack>
+ ),
+};
+
+export const EqualFill: Story = {
+ render: () => (
+ <div>
+ <h4 {...stylex.props(styles.heading)}>Equal Fill (1:1:1)</h4>
+ <XDSHStack gap="space2" xstyle={[styles.container, styles.containerWidth, styles.containerPadding]}>
+ <XDSStackItem size="fill">
+ <Box>fill</Box>
+ </XDSStackItem>
+ <XDSStackItem size="fill">
+ <Box green>fill</Box>
+ </XDSStackItem>
+ <XDSStackItem size="fill">
+ <Box purple>fill</Box>
+ </XDSStackItem>
+ </XDSHStack>
+ </div>
+ ),
+};
+
+export const CrossAlignSelf: Story = {
+ render: () => (
+ <XDSHStack gap="space2" xstyle={[styles.container, styles.containerHeight, styles.containerPadding]}>
+ <XDSStackItem crossAlignSelf="start">
+ <Box>start</Box>
+ </XDSStackItem>
+ <XDSStackItem crossAlignSelf="center">
+ <Box green>center</Box>
+ </XDSStackItem>
+ <XDSStackItem crossAlignSelf="end">
+ <Box purple>end</Box>
+ </XDSStackItem>
+ <XDSStackItem crossAlignSelf="stretch">
+ <Box orange>stretch</Box>
+ </XDSStackItem>
+ </XDSHStack>
+ ),
+};
+
+export const PolymorphicElement: Story = {
+ render: () => (
+ <XDSHStack gap="space2" xstyle={[styles.container, styles.containerWidth, styles.containerPadding]}>
+ <XDSStackItem element="section" size="fill">
+ <Box>section element</Box>
+ </XDSStackItem>
+ <XDSStackItem element="article" size="fill">
+ <Box green>article element</Box>
+ </XDSStackItem>
+ <XDSStackItem element="aside" size="static">
+ <Box purple>aside element</Box>
+ </XDSStackItem>
+ </XDSHStack>
+ ),
+};
+
+export const CommonLayoutPattern: Story = {
+ render: () => (
+ <XDSVStack gap="space4">
+ <div>
+ <h4 {...stylex.props(styles.heading)}>Header Layout</h4>
+ <XDSHStack gap="space2" xstyle={[styles.container, styles.containerWidthLarge, styles.containerPadding]}>
+ <XDSStackItem size="static">
+ <Box alt>Logo</Box>
+ </XDSStackItem>
+ <XDSStackItem size="fill">
+ <Box>Navigation</Box>
+ </XDSStackItem>
+ <XDSStackItem size="static">
+ <Box alt>Actions</Box>
+ </XDSStackItem>
+ </XDSHStack>
+ </div>
+ <div>
+ <h4 {...stylex.props(styles.heading)}>Sidebar Layout</h4>
+ <XDSHStack gap="space2" xstyle={[styles.container, styles.containerWidthLarge, styles.containerHeightLarge, styles.containerPadding]}>
+ <XDSStackItem size="static" xstyle={styles.sidebarWidth}>
+ <Box alt>Sidebar</Box>
+ </XDSStackItem>
+ <XDSStackItem size="fill">
+ <Box>Main Content</Box>
+ </XDSStackItem>
+ </XDSHStack>
+ </div>
+ </XDSVStack>
+ ),
+};
diff --git a/apps/storybook/stories/VStack.stories.tsx b/apps/storybook/stories/VStack.stories.tsx
new file mode 100644
index 0000000000..304ee522df
--- /dev/null
+++ b/apps/storybook/stories/VStack.stories.tsx
@@ -0,0 +1,206 @@
+import type { Meta, StoryObj } from '@storybook/react';
+import * as stylex from '@stylexjs/stylex';
+import { XDSVStack } from '@xds/core/Layout';
+import {
+ colorTokens,
+ spacingTokens,
+ radiusTokens,
+ typographyTokens,
+} from '@xds/core/theme/tokens.stylex';
+
+const styles = stylex.create({
+ box: {
+ backgroundColor: colorTokens.blueBackground,
+ color: colorTokens.blueText,
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: colorTokens.blueBorder,
+ paddingBlock: spacingTokens.space4,
+ paddingInline: spacingTokens.space6,
+ borderRadius: radiusTokens.element,
+ fontWeight: 500,
+ },
+ boxAlt: {
+ backgroundColor: colorTokens.grayBackground,
+ color: colorTokens.grayText,
+ borderColor: colorTokens.grayBorder,
+ },
+ container: {
+ backgroundColor: colorTokens.wash,
+ },
+ containerWidth: {
+ width: 300,
+ },
+ containerWidthSmall: {
+ width: 150,
+ },
+ containerHeight: {
+ height: 150,
+ },
+ containerPadding: {
+ padding: spacingTokens.space2,
+ },
+ storyWrapper: {
+ display: 'flex',
+ gap: spacingTokens.space6,
+ },
+ heading: {
+ margin: `0 0 ${spacingTokens.space2} 0`,
+ fontFamily: typographyTokens.fontFamilyBody,
+ },
+});
+
+// Demo box component for visibility
+const Box = ({ children, alt = false }: { children: React.ReactNode; alt?: boolean }) => (
+ <div {...stylex.props(styles.box, alt && styles.boxAlt)}>{children}</div>
+);
+
+const meta: Meta<typeof XDSVStack> = {
+ title: 'Layout/XDSVStack',
+ component: XDSVStack,
+ tags: ['autodocs'],
+ argTypes: {
+ gap: {
+ control: 'select',
+ options: ['space0', 'space0.5', 'space1', 'space2', 'space3', 'space4', 'space5', 'space6', 'space7'],
+ description: 'Spacing token for gap between items',
+ },
+ hAlign: {
+ control: 'select',
+ options: ['start', 'center', 'end', 'stretch'],
+ description: 'Horizontal alignment of items',
+ },
+ wrap: {
+ control: 'select',
+ options: ['nowrap', 'wrap', 'wrap-reverse'],
+ description: 'Flex wrap behavior',
+ },
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof XDSVStack>;
+
+export const Default: Story = {
+ args: {
+ gap: 'space2',
+ children: null,
+ },
+ render: (args) => (
+ <XDSVStack {...args}>
+ <Box>Item 1</Box>
+ <Box>Item 2</Box>
+ <Box>Item 3</Box>
+ </XDSVStack>
+ ),
+};
+
+export const WithGap: Story = {
+ args: {
+ gap: 'space4',
+ },
+ render: (args) => (
+ <XDSVStack {...args}>
+ <Box>Item 1</Box>
+ <Box>Item 2</Box>
+ <Box>Item 3</Box>
+ </XDSVStack>
+ ),
+};
+
+export const HorizontalAlignCenter: Story = {
+ args: {
+ gap: 'space4',
+ hAlign: 'center',
+ },
+ render: (args) => (
+ <XDSVStack {...args} xstyle={[styles.container, styles.containerWidth]}>
+ <Box>Short</Box>
+ <Box>Medium Item</Box>
+ <Box>Short</Box>
+ </XDSVStack>
+ ),
+};
+
+export const HorizontalAlignStart: Story = {
+ args: {
+ gap: 'space4',
+ hAlign: 'start',
+ },
+ render: (args) => (
+ <XDSVStack {...args} xstyle={[styles.container, styles.containerWidth]}>
+ <Box>Short</Box>
+ <Box>Medium Item</Box>
+ <Box>Short</Box>
+ </XDSVStack>
+ ),
+};
+
+export const HorizontalAlignEnd: Story = {
+ args: {
+ gap: 'space4',
+ hAlign: 'end',
+ },
+ render: (args) => (
+ <XDSVStack {...args} xstyle={[styles.container, styles.containerWidth]}>
+ <Box>Short</Box>
+ <Box>Medium Item</Box>
+ <Box>Short</Box>
+ </XDSVStack>
+ ),
+};
+
+export const Wrapping: Story = {
+ args: {
+ gap: 'space2',
+ wrap: 'wrap',
+ },
+ render: (args) => (
+ <XDSVStack {...args} xstyle={[styles.container, styles.containerHeight, styles.containerPadding]}>
+ <Box>Item 1</Box>
+ <Box>Item 2</Box>
+ <Box>Item 3</Box>
+ <Box>Item 4</Box>
+ <Box>Item 5</Box>
+ </XDSVStack>
+ ),
+};
+
+export const AllAlignments: Story = {
+ render: () => (
+ <div {...stylex.props(styles.storyWrapper)}>
+ <div>
+ <h4 {...stylex.props(styles.heading)}>hAlign: start</h4>
+ <XDSVStack gap="space2" hAlign="start" xstyle={[styles.container, styles.containerWidthSmall, styles.containerPadding]}>
+ <Box>A</Box>
+ <Box>BB</Box>
+ <Box>CCC</Box>
+ </XDSVStack>
+ </div>
+ <div>
+ <h4 {...stylex.props(styles.heading)}>hAlign: center</h4>
+ <XDSVStack gap="space2" hAlign="center" xstyle={[styles.container, styles.containerWidthSmall, styles.containerPadding]}>
+ <Box>A</Box>
+ <Box>BB</Box>
+ <Box>CCC</Box>
+ </XDSVStack>
+ </div>
+ <div>
+ <h4 {...stylex.props(styles.heading)}>hAlign: end</h4>
+ <XDSVStack gap="space2" hAlign="end" xstyle={[styles.container, styles.containerWidthSmall, styles.containerPadding]}>
+ <Box>A</Box>
+ <Box>BB</Box>
+ <Box>CCC</Box>
+ </XDSVStack>
+ </div>
+ <div>
+ <h4 {...stylex.props(styles.heading)}>hAlign: stretch</h4>
+ <XDSVStack gap="space2" hAlign="stretch" xstyle={[styles.container, styles.containerWidthSmall, styles.containerPadding]}>
+ <Box>A</Box>
+ <Box>BB</Box>
+ <Box>CCC</Box>
+ </XDSVStack>
+ </div>
+ </div>
+ ),
+};
diff --git a/apps/storybook/tsconfig.json b/apps/storybook/tsconfig.json
index 081038cf3e..718bd90ca6 100644
--- a/apps/storybook/tsconfig.json
+++ b/apps/storybook/tsconfig.json
@@ -3,8 +3,8 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
- "@xds/core": ["../../packages/core/dist"],
- "@xds/core/*": ["../../packages/core/dist/*"]
+ "@xds/core": ["../../packages/core/src"],
+ "@xds/core/*": ["../../packages/core/src/*"]
}
},
"include": [".storybook/**/*", "stories/**/*"]
diff --git a/apps/storybook/vite.config.ts b/apps/storybook/vite.config.ts
index ba7be907ec..05c3a5a4aa 100644
--- a/apps/storybook/vite.config.ts
+++ b/apps/storybook/vite.config.ts
@@ -9,7 +9,12 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
-import babelrc from './.babelrc.cjs';
+import path from 'path';
+
+// eslint-disable-next-line @typescript-eslint/no-require-imports
+const babelrc = require('./.babelrc.cjs');
+
+const coreRoot = path.resolve(__dirname, '../../packages/core/src');
export default defineConfig({
plugins: [
@@ -17,6 +22,12 @@ export default defineConfig({
babel: babelrc,
}),
],
+ resolve: {
+ alias: {
+ // Map @xds/core to source for StyleX compilation
+ '@xds/core': coreRoot,
+ },
+ },
optimizeDeps: {
include: ['react', 'react-dom'],
},
diff --git a/packages/core/package.json b/packages/core/package.json
index bcccc94e37..1adbe66e36 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -20,6 +20,11 @@
"types": "./dist/Button/index.d.ts",
"import": "./dist/Button/index.mjs",
"require": "./dist/Button/index.js"
+ },
+ "./Layout": {
+ "types": "./dist/Layout/index.d.ts",
+ "import": "./dist/Layout/index.mjs",
+ "require": "./dist/Layout/index.js"
}
},
"scripts": {
diff --git a/packages/core/src/Layout/README.md b/packages/core/src/Layout/README.md
new file mode 100644
index 0000000000..6d0851d8ab
--- /dev/null
+++ b/packages/core/src/Layout/README.md
@@ -0,0 +1,85 @@
+# /packages/core/src/Layout
+
+XDS Layout System - composable utilities and components for building structured layouts.
+
+<!-- SYNC: When files in this directory change, update this document. -->
+
+## Overview
+
+The layout system provides a container/content separation pattern with:
+- Zero styling customization (no xstyle props)
+- Context-aware defaults
+- Automatic RTL support via logical properties
+- Polymorphic rendering support
+
+## Import
+
+All layout utilities and components are exported from `@xds/core/Layout`:
+
+```tsx
+import {
+ XDSHStack,
+ XDSVStack,
+ XDSStackItem,
+ stack,
+ stackItem
+} from '@xds/core/Layout';
+```
+
+## Structure
+
+```
+Layout/
+├── index.ts # Entry point, re-exports everything
+├── Stack/ # Stack utilities and components
+│ ├── index.ts
+│ ├── README.md # Stack documentation
+│ ├── stack.stylex.ts
+│ ├── stackItem.stylex.ts
+│ ├── XDSHStack.tsx
+│ ├── XDSHStack.test.tsx
+│ ├── XDSVStack.tsx
+│ ├── XDSVStack.test.tsx
+│ ├── XDSStackItem.tsx
+│ └── XDSStackItem.test.tsx
+└── README.md
+```
+
+## Available Components
+
+### Stack Components
+
+Stack layout primitives for arranging items in horizontal or vertical sequences.
+
+See [Stack/README.md](./Stack/README.md) for full documentation.
+
+| Component | Description |
+|-----------|-------------|
+| `XDSHStack` | Horizontal stack (left-to-right) |
+| `XDSVStack` | Vertical stack (top-to-bottom) |
+| `XDSStackItem` | Stack item with fill/alignment control |
+
+Quick example:
+
+```tsx
+<XDSHStack gap="space2">
+ <XDSStackItem size="static">Logo</XDSStackItem>
+ <XDSStackItem size="fill">Content</XDSStackItem>
+ <XDSStackItem size="static">Actions</XDSStackItem>
+</XDSHStack>
+```
+
+## Components (Planned)
+
+| Component | Status | Description |
+|-----------|--------|-------------|
+| `XDSLayoutContainer` | Planned | Outer container with variant-based styling |
+| `XDSLayout` | Planned | Section arrangement with named slots |
+| `XDSLayoutHeader` | Planned | Header content area |
+| `XDSLayoutFooter` | Planned | Footer content area |
+| `XDSLayoutContent` | Planned | Main content area |
+| `XDSLayoutPanel` | Planned | Side panel content area |
+
+## Related
+
+- See `.context/proposals/layout-system.md` for full design proposal
diff --git a/packages/core/src/Layout/Stack/README.md b/packages/core/src/Layout/Stack/README.md
new file mode 100644
index 0000000000..881508ff9d
--- /dev/null
+++ b/packages/core/src/Layout/Stack/README.md
@@ -0,0 +1,242 @@
+# /packages/core/src/Layout/Stack
+
+Stack layout primitives for arranging items in horizontal or vertical sequences.
+
+<!-- SYNC: When files in this directory change, update this document. -->
+
+## Overview
+
+The Stack system provides flexbox-based layout components with:
+- Horizontal (`XDSHStack`) and vertical (`XDSVStack`) stacking
+- Themed spacing via gap tokens
+- Individual item control via `XDSStackItem`
+- Polymorphic rendering support
+
+## Import
+
+```tsx
+import {
+ XDSHStack,
+ XDSVStack,
+ XDSStackItem,
+ stack,
+ stackItem
+} from '@xds/core/Layout';
+```
+
+## Components
+
+### XDSHStack
+
+Horizontal stack for arranging items left-to-right. Supports polymorphic rendering.
+
+```tsx
+// Basic horizontal stack
+<XDSHStack gap="space2">
+ <Item />
+ <Item />
+</XDSHStack>
+
+// With alignment
+<XDSHStack gap="space4" vAlign="center">
+ <Item />
+ <Item />
+</XDSHStack>
+
+// Polymorphic rendering
+<XDSHStack element="nav" gap="space2">
+ <Link />
+ <Link />
+</XDSHStack>
+```
+
+| Prop | Type | Default | Description |
+|------|------|---------|-------------|
+| `gap` | `SpacingScale` | — | Spacing token between items |
+| `vAlign` | `'start' \| 'center' \| 'end' \| 'stretch'` | `'stretch'` | Vertical alignment |
+| `wrap` | `'nowrap' \| 'wrap' \| 'wrap-reverse'` | `'nowrap'` | Flex wrap behavior |
+| `element` | `ElementType` | `'div'` | HTML element to render |
+| `children` | `ReactNode` | — | Stack content |
+
+### XDSVStack
+
+Vertical stack for arranging items top-to-bottom. Supports polymorphic rendering.
+
+```tsx
+// Basic vertical stack
+<XDSVStack gap="space2">
+ <Item />
+ <Item />
+</XDSVStack>
+
+// With alignment
+<XDSVStack gap="space4" hAlign="center">
+ <Item />
+ <Item />
+</XDSVStack>
+
+// Polymorphic rendering
+<XDSVStack element="main" gap="space4">
+ <Header />
+ <Content />
+</XDSVStack>
+```
+
+| Prop | Type | Default | Description |
+|------|------|---------|-------------|
+| `gap` | `SpacingScale` | — | Spacing token between items |
+| `hAlign` | `'start' \| 'center' \| 'end' \| 'stretch'` | `'stretch'` | Horizontal alignment |
+| `wrap` | `'nowrap' \| 'wrap' \| 'wrap-reverse'` | `'nowrap'` | Flex wrap behavior |
+| `element` | `ElementType` | `'div'` | HTML element to render |
+| `children` | `ReactNode` | — | Stack content |
+
+### XDSStackItem
+
+Stack item for controlling individual item behavior within a stack. Supports polymorphic rendering.
+
+```tsx
+// Basic usage with fill
+<XDSHStack gap="space2">
+ <XDSStackItem size="static">Logo</XDSStackItem>
+ <XDSStackItem size="fill">Content</XDSStackItem>
+ <XDSStackItem size="static">Actions</XDSStackItem>
+</XDSHStack>
+
+// Override alignment
+<XDSHStack vAlign="start">
+ <XDSStackItem crossAlignSelf="center">Centered</XDSStackItem>
+ <XDSStackItem>Top-aligned</XDSStackItem>
+</XDSHStack>
+
+// Polymorphic rendering
+<XDSStackItem element="section" size="fill">
+ Section content
+</XDSStackItem>
+```
+
+| Prop | Type | Default | Description |
+|------|------|---------|-------------|
+| `size` | `'static' \| 'fill'` | `'static'` | Flex grow behavior |
+| `crossAlignSelf` | `'start' \| 'center' \| 'end' \| 'stretch'` | — | Override cross-axis alignment |
+| `element` | `ElementType` | `'div'` | HTML element to render |
+| `children` | `ReactNode` | — | Item content |
+
+## Utilities
+
+For advanced use cases, you can use the underlying StyleX utilities directly.
+
+### stack
+
+StyleX utility for creating flex containers.
+
+```tsx
+import { stack } from '@xds/core/Layout';
+import * as stylex from '@stylexjs/stylex';
+
+<div {...stylex.props(...stack({ direction: 'horizontal', gap: 'space2' }))}>
+ <Child />
+ <Child />
+</div>
+```
+
+| Option | Type | Default | Description |
+|--------|------|---------|-------------|
+| `direction` | `'horizontal' \| 'vertical'` | Required | Stack direction |
+| `gap` | `SpacingScale` | — | Spacing token between items |
+| `crossAlign` | `'start' \| 'center' \| 'end' \| 'stretch'` | — | Cross-axis alignment |
+| `wrap` | `'nowrap' \| 'wrap' \| 'wrap-reverse'` | `'nowrap'` | Flex wrap behavior |
+
+### stackItem
+
+StyleX utility for controlling flex item behavior.
+
+```tsx
+import { stackItem } from '@xds/core/Layout';
+import * as stylex from '@stylexjs/stylex';
+
+<div {...stylex.props(...stackItem({ size: 'fill' }))}>
+ Content
+</div>
+```
+
+| Option | Type | Default | Description |
+|--------|------|---------|-------------|
+| `size` | `'static' \| 'fill'` | `'static'` | Flex grow behavior |
+| `crossAlignSelf` | `'start' \| 'center' \| 'end' \| 'stretch'` | — | Override cross-axis alignment |
+
+## Spacing Scale
+
+The `gap` prop uses spacing tokens from the theme:
+
+| Token | Description |
+|-------|-------------|
+| `space0` | No spacing |
+| `space0.5` | Extra small spacing |
+| `space1` | Small spacing |
+| `space2` | Medium-small spacing |
+| `space3` | Medium spacing |
+| `space4` | Medium-large spacing |
+| `space5` | Large spacing |
+| `space6` | Extra large spacing |
+| `space7` | Maximum spacing |
+
+## Common Patterns
+
+### Header Layout
+
+```tsx
+<XDSHStack element="header" gap="space2">
+ <XDSStackItem size="static">
+ <Logo />
+ </XDSStackItem>
+ <XDSStackItem size="fill">
+ <Navigation />
+ </XDSStackItem>
+ <XDSStackItem size="static">
+ <UserMenu />
+ </XDSStackItem>
+</XDSHStack>
+```
+
+### Sidebar Layout
+
+```tsx
+<XDSHStack gap="space4">
+ <XDSStackItem size="static">
+ <Sidebar />
+ </XDSStackItem>
+ <XDSStackItem size="fill">
+ <MainContent />
+ </XDSStackItem>
+</XDSHStack>
+```
+
+### Page Layout
+
+```tsx
+<XDSVStack element="main" gap="space6">
+ <XDSStackItem size="static">
+ <PageHeader />
+ </XDSStackItem>
+ <XDSStackItem size="fill">
+ <PageContent />
+ </XDSStackItem>
+ <XDSStackItem size="static">
+ <PageFooter />
+ </XDSStackItem>
+</XDSVStack>
+```
+
+## Files
+
+| File | Role | Purpose |
+|------|------|---------|
+| `index.ts` | Entry | Exports all stack utilities and components |
+| `stack.stylex.ts` | Utility | StyleX styles for stack (flex container) behavior |
+| `stackItem.stylex.ts` | Utility | StyleX styles for stack item behavior |
+| `XDSHStack.tsx` | Component | Horizontal stack component |
+| `XDSHStack.test.tsx` | Test | XDSHStack unit tests |
+| `XDSVStack.tsx` | Component | Vertical stack component |
+| `XDSVStack.test.tsx` | Test | XDSVStack unit tests |
+| `XDSStackItem.tsx` | Component | Stack item wrapper component |
+| `XDSStackItem.test.tsx` | Test | XDSStackItem unit tests |
diff --git a/packages/core/src/Layout/Stack/XDSHStack.test.tsx b/packages/core/src/Layout/Stack/XDSHStack.test.tsx
new file mode 100644
index 0000000000..c5f84201e8
--- /dev/null
+++ b/packages/core/src/Layout/Stack/XDSHStack.test.tsx
@@ -0,0 +1,99 @@
+/**
+ * @file XDSHStack.test.tsx
+ * @input Uses vitest, @testing-library/react, XDSHStack component
+ * @output Unit tests for XDSHStack component behavior
+ * @position Testing; validates XDSHStack.tsx implementation
+ *
+ * SYNC: When XDSHStack.tsx changes, update tests to match new behavior
+ */
+
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen } from '@testing-library/react';
+import { XDSHStack } from './XDSHStack';
+
+describe('XDSHStack', () => {
+ it('renders children correctly', () => {
+ render(
+ <XDSHStack>
+ <div>Item 1</div>
+ <div>Item 2</div>
+ </XDSHStack>
+ );
+ expect(screen.getByText('Item 1')).toBeInTheDocument();
+ expect(screen.getByText('Item 2')).toBeInTheDocument();
+ });
+
+ it('renders as div by default', () => {
+ render(<XDSHStack data-testid="hstack">Content</XDSHStack>);
+ const element = screen.getByTestId('hstack');
+ expect(element.tagName).toBe('DIV');
+ });
+
+ it('renders with polymorphic element prop', () => {
+ render(
+ <XDSHStack element="nav" data-testid="hstack">
+ Content
+ </XDSHStack>
+ );
+ const element = screen.getByTestId('hstack');
+ expect(element.tagName).toBe('NAV');
+ });
+
+ it('renders with gap prop', () => {
+ render(
+ <XDSHStack gap="space4">
+ <div>Item 1</div>
+ <div>Item 2</div>
+ </XDSHStack>
+ );
+ expect(screen.getByText('Item 1')).toBeInTheDocument();
+ });
+
+ it('renders with vAlign prop', () => {
+ render(
+ <XDSHStack vAlign="center">
+ <div>Item 1</div>
+ </XDSHStack>
+ );
+ expect(screen.getByText('Item 1')).toBeInTheDocument();
+ });
+
+ it('renders with wrap prop', () => {
+ render(
+ <XDSHStack wrap="wrap">
+ <div>Item 1</div>
+ <div>Item 2</div>
+ </XDSHStack>
+ );
+ expect(screen.getByText('Item 1')).toBeInTheDocument();
+ });
+
+ it('forwards ref correctly', () => {
+ const ref = vi.fn();
+ render(
+ <XDSHStack ref={ref}>
+ <div>Test</div>
+ </XDSHStack>
+ );
+ expect(ref).toHaveBeenCalledWith(expect.any(HTMLElement));
+ });
+
+ it('forwards ref with polymorphic element', () => {
+ const ref = vi.fn();
+ render(
+ <XDSHStack element="section" ref={ref}>
+ <div>Test</div>
+ </XDSHStack>
+ );
+ expect(ref).toHaveBeenCalledWith(expect.any(HTMLElement));
+ });
+
+ it('passes through additional props', () => {
+ render(
+ <XDSHStack data-testid="hstack">
+ <div>Item</div>
+ </XDSHStack>
+ );
+ expect(screen.getByTestId('hstack')).toBeInTheDocument();
+ });
+});
diff --git a/packages/core/src/Layout/Stack/XDSHStack.tsx b/packages/core/src/Layout/Stack/XDSHStack.tsx
new file mode 100644
index 0000000000..e5c2f2f2be
--- /dev/null
+++ b/packages/core/src/Layout/Stack/XDSHStack.tsx
@@ -0,0 +1,110 @@
+/**
+ * @file XDSHStack.tsx
+ * @input Uses React forwardRef, ElementType, stack utility
+ * @output Exports XDSHStack polymorphic component and XDSHStackProps
+ * @position Layout/Stack component; uses stack.stylex.ts
+ *
+ * SYNC: When modified, update these files to stay in sync:
+ * - /packages/core/src/Layout/Stack/README.md
+ * - /packages/core/src/Layout/Stack/XDSHStack.test.tsx
+ * - /apps/storybook/stories/HStack.stories.tsx
+ */
+
+import {
+ forwardRef,
+ createElement,
+ type ElementType,
+ type HTMLAttributes,
+ type ReactNode,
+ type Ref,
+} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import type { StyleXStyles } from '@stylexjs/stylex';
+import { stack, type StackCrossAlignment, type StackWrap, type SpacingScale } from './stack.stylex';
+
+export interface XDSHStackProps extends Omit<HTMLAttributes<HTMLElement>, 'style' | 'className'> {
+ /**
+ * Vertical alignment of items (cross-axis for horizontal stack).
+ * @default 'stretch'
+ */
+ vAlign?: StackCrossAlignment;
+
+ /**
+ * Spacing between items using theme spacing tokens.
+ * Use token names: 'space0', 'space1', 'space2', 'space3', 'space4', 'space5', 'space6', 'space7'
+ */
+ gap?: SpacingScale;
+
+ /**
+ * Whether items should wrap.
+ * - `nowrap`: Items stay on one line (default)
+ * - `wrap`: Items wrap to next line
+ * - `wrap-reverse`: Items wrap to previous line
+ * @default 'nowrap'
+ */
+ wrap?: StackWrap;
+
+ /**
+ * The element type to render.
+ * @default 'div'
+ */
+ element?: ElementType;
+
+ /**
+ * StyleX styles to apply to the stack.
+ */
+ xstyle?: StyleXStyles;
+
+ /**
+ * Content to render inside the stack.
+ */
+ children?: ReactNode;
+}
+
+/**
+ * Horizontal stack component for arranging items left-to-right.
+ *
+ * Uses the stack utility internally with `direction: 'horizontal'`.
+ * The `vAlign` prop controls vertical alignment of items.
+ * Supports polymorphic rendering via the `element` prop.
+ *
+ * @example
+ * ```tsx
+ * <XDSHStack gap="space2">
+ * <Item />
+ * <Item />
+ * </XDSHStack>
+ * <XDSHStack gap="space4" vAlign="center">
+ * <Item />
+ * <Item />
+ * </XDSHStack>
+ * ```
+ */
+export const XDSHStack = forwardRef<HTMLElement, XDSHStackProps>(
+ function XDSHStack(
+ { vAlign, gap, wrap, element = 'div', xstyle, children, ...props },
+ ref
+ ) {
+ const stylexProps = stylex.props(
+ ...stack({
+ direction: 'horizontal',
+ crossAlign: vAlign,
+ gap,
+ wrap,
+ }),
+ xstyle
+ );
+
+ return createElement(
+ element,
+ {
+ ref: ref as Ref<Element>,
+ ...stylexProps,
+ ...props,
+ },
+ children
+ );
+ }
+);
+
+XDSHStack.displayName = 'XDSHStack';
diff --git a/packages/core/src/Layout/Stack/XDSStackItem.test.tsx b/packages/core/src/Layout/Stack/XDSStackItem.test.tsx
new file mode 100644
index 0000000000..a6c1fa59f5
--- /dev/null
+++ b/packages/core/src/Layout/Stack/XDSStackItem.test.tsx
@@ -0,0 +1,80 @@
+/**
+ * @file XDSStackItem.test.tsx
+ * @input Uses vitest, @testing-library/react, XDSStackItem component
+ * @output Unit tests for XDSStackItem component behavior
+ * @position Testing; validates XDSStackItem.tsx implementation
+ *
+ * SYNC: When XDSStackItem.tsx changes, update tests to match new behavior
+ */
+
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen } from '@testing-library/react';
+import { XDSStackItem } from './XDSStackItem';
+
+describe('XDSStackItem', () => {
+ it('renders children correctly', () => {
+ render(<XDSStackItem>Test content</XDSStackItem>);
+ expect(screen.getByText('Test content')).toBeInTheDocument();
+ });
+
+ it('renders as div by default', () => {
+ render(<XDSStackItem data-testid="stack-item">Content</XDSStackItem>);
+ const element = screen.getByTestId('stack-item');
+ expect(element.tagName).toBe('DIV');
+ });
+
+ it('renders with polymorphic element prop', () => {
+ render(
+ <XDSStackItem element="section" data-testid="stack-item">
+ Content
+ </XDSStackItem>
+ );
+ const element = screen.getByTestId('stack-item');
+ expect(element.tagName).toBe('SECTION');
+ });
+
+ it('renders with size prop', () => {
+ render(<XDSStackItem size="fill">Content</XDSStackItem>);
+ expect(screen.getByText('Content')).toBeInTheDocument();
+ });
+
+ it('renders with static size', () => {
+ render(<XDSStackItem size="static">Content</XDSStackItem>);
+ expect(screen.getByText('Content')).toBeInTheDocument();
+ });
+
+ it('renders with crossAlignSelf prop', () => {
+ render(<XDSStackItem crossAlignSelf="center">Content</XDSStackItem>);
+ expect(screen.getByText('Content')).toBeInTheDocument();
+ });
+
+ it('forwards ref correctly', () => {
+ const ref = vi.fn();
+ render(
+ <XDSStackItem ref={ref}>
+ <div>Test</div>
+ </XDSStackItem>
+ );
+ expect(ref).toHaveBeenCalledWith(expect.any(HTMLDivElement));
+ });
+
+ it('forwards ref with polymorphic element', () => {
+ const ref = vi.fn();
+ render(
+ <XDSStackItem element="section" ref={ref}>
+ <div>Test</div>
+ </XDSStackItem>
+ );
+ expect(ref).toHaveBeenCalledWith(expect.any(HTMLElement));
+ });
+
+ it('passes through additional props', () => {
+ render(
+ <XDSStackItem data-testid="stack-item" aria-label="Stack item">
+ Content
+ </XDSStackItem>
+ );
+ const element = screen.getByTestId('stack-item');
+ expect(element).toHaveAttribute('aria-label', 'Stack item');
+ });
+});
diff --git a/packages/core/src/Layout/Stack/XDSStackItem.tsx b/packages/core/src/Layout/Stack/XDSStackItem.tsx
new file mode 100644
index 0000000000..a39fd99084
--- /dev/null
+++ b/packages/core/src/Layout/Stack/XDSStackItem.tsx
@@ -0,0 +1,91 @@
+/**
+ * @file XDSStackItem.tsx
+ * @input Uses React forwardRef, ElementType, stackItem utility
+ * @output Exports XDSStackItem polymorphic component and XDSStackItemProps
+ * @position Layout/Stack component; uses stackItem.stylex.ts
+ *
+ * SYNC: When modified, update these files to stay in sync:
+ * - /packages/core/src/Layout/README.md
+ * - /packages/core/src/Layout/Stack/XDSStackItem.test.tsx
+ * - /apps/storybook/stories/StackItem.stories.tsx
+ */
+
+import {
+ forwardRef,
+ createElement,
+ type ElementType,
+ type HTMLAttributes,
+ type ReactNode,
+ type Ref,
+} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import type { StyleXStyles } from '@stylexjs/stylex';
+import { stackItem, type StackItemCrossAlignSelf, type StackItemSize } from './stackItem.stylex';
+
+export interface XDSStackItemProps extends Omit<HTMLAttributes<HTMLElement>, 'style' | 'className'> {
+ /**
+ * Overrides the default cross-alignment for this item.
+ * (hAlign for VStack, vAlign for HStack)
+ */
+ crossAlignSelf?: StackItemCrossAlignSelf;
+
+ /**
+ * Size behavior of the item within the stack.
+ * - `static`: Uses intrinsic size, won't grow or shrink (default)
+ * - `fill`: Grows to fill remaining space
+ *
+ * @default "static"
+ */
+ size?: StackItemSize;
+
+ /**
+ * The element type to render.
+ * @default 'div'
+ */
+ element?: ElementType;
+
+ /**
+ * StyleX styles to apply to the stack item.
+ */
+ xstyle?: StyleXStyles;
+
+ /**
+ * Content to render inside the stack item.
+ */
+ children?: ReactNode;
+}
+
+/**
+ * Stack item component for controlling individual item behavior within a stack.
+ *
+ * Supports polymorphic rendering via the `element` prop.
+ *
+ * @example
+ * ```tsx
+ * <XDSHStack gap="space2">
+ * <XDSStackItem size="static">Logo</XDSStackItem>
+ * <XDSStackItem size="fill">Content</XDSStackItem>
+ * <XDSStackItem size="static">Actions</XDSStackItem>
+ * </XDSHStack>
+ * ```
+ */
+export const XDSStackItem = forwardRef<HTMLElement, XDSStackItemProps>(
+ function XDSStackItem(
+ { crossAlignSelf, size, element = 'div', xstyle, children, ...props },
+ ref
+ ) {
+ const stylexProps = stylex.props(...stackItem({ crossAlignSelf, size }), xstyle);
+
+ return createElement(
+ element,
+ {
+ ref: ref as Ref<Element>,
+ ...stylexProps,
+ ...props,
+ },
+ children
+ );
+ }
+);
+
+XDSStackItem.displayName = 'XDSStackItem';
diff --git a/packages/core/src/Layout/Stack/XDSVStack.test.tsx b/packages/core/src/Layout/Stack/XDSVStack.test.tsx
new file mode 100644
index 0000000000..be34ccae52
--- /dev/null
+++ b/packages/core/src/Layout/Stack/XDSVStack.test.tsx
@@ -0,0 +1,99 @@
+/**
+ * @file XDSVStack.test.tsx
+ * @input Uses vitest, @testing-library/react, XDSVStack component
+ * @output Unit tests for XDSVStack component behavior
+ * @position Testing; validates XDSVStack.tsx implementation
+ *
+ * SYNC: When XDSVStack.tsx changes, update tests to match new behavior
+ */
+
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen } from '@testing-library/react';
+import { XDSVStack } from './XDSVStack';
+
+describe('XDSVStack', () => {
+ it('renders children correctly', () => {
+ render(
+ <XDSVStack>
+ <div>Item 1</div>
+ <div>Item 2</div>
+ </XDSVStack>
+ );
+ expect(screen.getByText('Item 1')).toBeInTheDocument();
+ expect(screen.getByText('Item 2')).toBeInTheDocument();
+ });
+
+ it('renders as div by default', () => {
+ render(<XDSVStack data-testid="vstack">Content</XDSVStack>);
+ const element = screen.getByTestId('vstack');
+ expect(element.tagName).toBe('DIV');
+ });
+
+ it('renders with polymorphic element prop', () => {
+ render(
+ <XDSVStack element="main" data-testid="vstack">
+ Content
+ </XDSVStack>
+ );
+ const element = screen.getByTestId('vstack');
+ expect(element.tagName).toBe('MAIN');
+ });
+
+ it('renders with gap prop', () => {
+ render(
+ <XDSVStack gap="space4">
+ <div>Item 1</div>
+ <div>Item 2</div>
+ </XDSVStack>
+ );
+ expect(screen.getByText('Item 1')).toBeInTheDocument();
+ });
+
+ it('renders with hAlign prop', () => {
+ render(
+ <XDSVStack hAlign="center">
+ <div>Item 1</div>
+ </XDSVStack>
+ );
+ expect(screen.getByText('Item 1')).toBeInTheDocument();
+ });
+
+ it('renders with wrap prop', () => {
+ render(
+ <XDSVStack wrap="wrap">
+ <div>Item 1</div>
+ <div>Item 2</div>
+ </XDSVStack>
+ );
+ expect(screen.getByText('Item 1')).toBeInTheDocument();
+ });
+
+ it('forwards ref correctly', () => {
+ const ref = vi.fn();
+ render(
+ <XDSVStack ref={ref}>
+ <div>Test</div>
+ </XDSVStack>
+ );
+ expect(ref).toHaveBeenCalledWith(expect.any(HTMLElement));
+ });
+
+ it('forwards ref with polymorphic element', () => {
+ const ref = vi.fn();
+ render(
+ <XDSVStack element="section" ref={ref}>
+ <div>Test</div>
+ </XDSVStack>
+ );
+ expect(ref).toHaveBeenCalledWith(expect.any(HTMLElement));
+ });
+
+ it('passes through additional props', () => {
+ render(
+ <XDSVStack data-testid="vstack">
+ <div>Item</div>
+ </XDSVStack>
+ );
+ expect(screen.getByTestId('vstack')).toBeInTheDocument();
+ });
+});
diff --git a/packages/core/src/Layout/Stack/XDSVStack.tsx b/packages/core/src/Layout/Stack/XDSVStack.tsx
new file mode 100644
index 0000000000..d812dd4581
--- /dev/null
+++ b/packages/core/src/Layout/Stack/XDSVStack.tsx
@@ -0,0 +1,110 @@
+/**
+ * @file XDSVStack.tsx
+ * @input Uses React forwardRef, ElementType, stack utility
+ * @output Exports XDSVStack polymorphic component and XDSVStackProps
+ * @position Layout/Stack component; uses stack.stylex.ts
+ *
+ * SYNC: When modified, update these files to stay in sync:
+ * - /packages/core/src/Layout/Stack/README.md
+ * - /packages/core/src/Layout/Stack/XDSVStack.test.tsx
+ * - /apps/storybook/stories/VStack.stories.tsx
+ */
+
+import {
+ forwardRef,
+ createElement,
+ type ElementType,
+ type HTMLAttributes,
+ type ReactNode,
+ type Ref,
+} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import type { StyleXStyles } from '@stylexjs/stylex';
+import { stack, type StackCrossAlignment, type StackWrap, type SpacingScale } from './stack.stylex';
+
+export interface XDSVStackProps extends Omit<HTMLAttributes<HTMLElement>, 'style' | 'className'> {
+ /**
+ * Horizontal alignment of items (cross-axis for vertical stack).
+ * @default 'stretch'
+ */
+ hAlign?: StackCrossAlignment;
+
+ /**
+ * Spacing between items using theme spacing tokens.
+ * Use token names: 'space0', 'space1', 'space2', 'space3', 'space4', 'space5', 'space6', 'space7'
+ */
+ gap?: SpacingScale;
+
+ /**
+ * Whether items should wrap.
+ * - `nowrap`: Items stay on one line (default)
+ * - `wrap`: Items wrap to next line
+ * - `wrap-reverse`: Items wrap to previous line
+ * @default 'nowrap'
+ */
+ wrap?: StackWrap;
+
+ /**
+ * The element type to render.
+ * @default 'div'
+ */
+ element?: ElementType;
+
+ /**
+ * StyleX styles to apply to the stack.
+ */
+ xstyle?: StyleXStyles;
+
+ /**
+ * Content to render inside the stack.
+ */
+ children?: ReactNode;
+}
+
+/**
+ * Vertical stack component for arranging items top-to-bottom.
+ *
+ * Uses the stack utility internally with `direction: 'vertical'`.
+ * The `hAlign` prop controls horizontal alignment of items.
+ * Supports polymorphic rendering via the `element` prop.
+ *
+ * @example
+ * ```tsx
+ * <XDSVStack gap="space2">
+ * <Item />
+ * <Item />
+ * </XDSVStack>
+ * <XDSVStack gap="space4" hAlign="center">
+ * <Item />
+ * <Item />
+ * </XDSVStack>
+ * ```
+ */
+export const XDSVStack = forwardRef<HTMLElement, XDSVStackProps>(
+ function XDSVStack(
+ { hAlign, gap, wrap, element = 'div', xstyle, children, ...props },
+ ref
+ ) {
+ const stylexProps = stylex.props(
+ ...stack({
+ direction: 'vertical',
+ crossAlign: hAlign,
+ gap,
+ wrap,
+ }),
+ xstyle
+ );
+
+ return createElement(
+ element,
+ {
+ ref: ref as Ref<Element>,
+ ...stylexProps,
+ ...props,
+ },
+ children
+ );
+ }
+);
+
+XDSVStack.displayName = 'XDSVStack';
diff --git a/packages/core/src/Layout/Stack/index.ts b/packages/core/src/Layout/Stack/index.ts
new file mode 100644
index 0000000000..16ef1aa728
--- /dev/null
+++ b/packages/core/src/Layout/Stack/index.ts
@@ -0,0 +1,35 @@
+/**
+ * @file index.ts
+ * @input Imports stack utilities and components
+ * @output Exports stack utilities and XDSHStack/XDSVStack/XDSStackItem components
+ * @position Entry point for Layout/Stack
+ *
+ * SYNC: When modified, update /packages/core/src/Layout/README.md
+ */
+
+// Utilities
+export { stack } from './stack.stylex';
+export type {
+ StackOptions,
+ StackDirection,
+ StackCrossAlignment,
+ StackWrap,
+ SpacingScale,
+} from './stack.stylex';
+
+export { stackItem } from './stackItem.stylex';
+export type {
+ StackItemOptions,
+ StackItemCrossAlignSelf,
+ StackItemSize,
+} from './stackItem.stylex';
+
+// Components
+export { XDSHStack } from './XDSHStack';
+export type { XDSHStackProps } from './XDSHStack';
+
+export { XDSVStack } from './XDSVStack';
+export type { XDSVStackProps } from './XDSVStack';
+
+export { XDSStackItem } from './XDSStackItem';
+export type { XDSStackItemProps } from './XDSStackItem';
diff --git a/packages/core/src/Layout/Stack/stack.stylex.ts b/packages/core/src/Layout/Stack/stack.stylex.ts
new file mode 100644
index 0000000000..d4fc86458c
--- /dev/null
+++ b/packages/core/src/Layout/Stack/stack.stylex.ts
@@ -0,0 +1,196 @@
+/**
+ * @file stack.stylex.ts
+ * @input Uses @stylexjs/stylex, spacingTokens from theme
+ * @output StyleX utility for stack (flex container) styling
+ * @position Layout utility; used by XDSHStack, XDSVStack components
+ *
+ * SYNC: When modified, update /packages/core/src/Layout/README.md
+ */
+
+import * as stylex from '@stylexjs/stylex';
+import { spacingTokens } from '../../theme/tokens.stylex';
+
+const alignItemsStyles = stylex.create({
+ center: {
+ alignItems: 'center',
+ },
+ end: {
+ alignItems: 'flex-end',
+ },
+ start: {
+ alignItems: 'flex-start',
+ },
+ stretch: {
+ alignItems: 'stretch',
+ },
+});
+
+/**
+ * Cross-axis alignment options for stack items.
+ * - For HStack: vertical alignment
+ * - For VStack: horizontal alignment
+ */
+export type StackCrossAlignment = keyof typeof alignItemsStyles;
+
+const directionStyles = stylex.create({
+ horizontal: {
+ flexDirection: 'row',
+ },
+ vertical: {
+ flexDirection: 'column',
+ },
+});
+
+/**
+ * Stack direction.
+ * - `horizontal`: Items flow left-to-right (HStack)
+ * - `vertical`: Items flow top-to-bottom (VStack)
+ */
+export type StackDirection = keyof typeof directionStyles;
+
+const wrapStyles = stylex.create({
+ nowrap: {
+ flexWrap: 'nowrap',
+ },
+ wrap: {
+ flexWrap: 'wrap',
+ },
+ 'wrap-reverse': {
+ flexWrap: 'wrap-reverse',
+ },
+});
+
+/**
+ * Flex wrap behavior.
+ * - `nowrap`: Items stay on one line (default)
+ * - `wrap`: Items wrap to next line
+ * - `wrap-reverse`: Items wrap to previous line
+ */
+export type StackWrap = keyof typeof wrapStyles;
+
+const baseStyles = stylex.create({
+ stack: {
+ display: 'flex',
+ },
+});
+
+/**
+ * Gap styles using spacing tokens from the theme.
+ * Keys match spacing token names for clarity.
+ */
+const gapStyles = stylex.create({
+ space0: {
+ columnGap: spacingTokens.space0,
+ rowGap: spacingTokens.space0,
+ },
+ 'space0.5': {
+ columnGap: spacingTokens.space0_5,
+ rowGap: spacingTokens.space0_5,
+ },
+ space1: {
+ columnGap: spacingTokens.space1,
+ rowGap: spacingTokens.space1,
+ },
+ space2: {
+ columnGap: spacingTokens.space2,
+ rowGap: spacingTokens.space2,
+ },
+ space3: {
+ columnGap: spacingTokens.space3,
+ rowGap: spacingTokens.space3,
+ },
+ space4: {
+ columnGap: spacingTokens.space4,
+ rowGap: spacingTokens.space4,
+ },
+ space5: {
+ columnGap: spacingTokens.space5,
+ rowGap: spacingTokens.space5,
+ },
+ space6: {
+ columnGap: spacingTokens.space6,
+ rowGap: spacingTokens.space6,
+ },
+ space7: {
+ columnGap: spacingTokens.space7,
+ rowGap: spacingTokens.space7,
+ },
+});
+
+/**
+ * Spacing token names for gap values.
+ * These match the theme's spacing token names.
+ */
+export type SpacingScale = keyof typeof gapStyles;
+
+export interface StackOptions {
+ /**
+ * Position of items along the cross-axis.
+ * - For HStack: vertical alignment
+ * - For VStack: horizontal alignment
+ */
+ crossAlign?: StackCrossAlignment;
+
+ /**
+ * Direction of the stack.
+ */
+ direction: StackDirection;
+
+ /**
+ * Spacing between items using theme spacing tokens.
+ * Use token names: 'space0', 'space1', 'space2', etc.
+ */
+ gap?: SpacingScale;
+
+ /**
+ * Whether items should wrap to the next line.
+ * - `nowrap`: Items stay on one line (default)
+ * - `wrap`: Items wrap to next line
+ * - `wrap-reverse`: Items wrap to previous line
+ * @default 'nowrap'
+ */
+ wrap?: StackWrap;
+}
+
+/**
+ * StyleX utility to add stack (flex container) styles to any element.
+ *
+ * @example
+ * ```tsx
+ * import { stack } from '@xds/core/Layout';
+ * import * as stylex from '@stylexjs/stylex';
+ *
+ * // Horizontal stack with gap
+ * <div {...stylex.props(...stack({ direction: 'horizontal', gap: 'space2' }))}>
+ * <Child />
+ * <Child />
+ * </div>
+ *
+ * // Vertical stack with centered items
+ * <div {...stylex.props(...stack({ direction: 'vertical', crossAlign: 'center' }))}>
+ * <Child />
+ * <Child />
+ * </div>
+ *
+ * // Wrapping horizontal stack with larger gap
+ * <div {...stylex.props(...stack({ direction: 'horizontal', gap: 'space4', wrap: 'wrap' }))}>
+ * <Child />
+ * <Child />
+ * <Child />
+ * </div>
+ * ```
+ */
+export function stack({
+ crossAlign,
+ direction,
+ gap,
+ wrap,
+}: StackOptions) {
+ return [
+ baseStyles.stack,
+ directionStyles[direction],
+ gap != null && gapStyles[gap],
+ crossAlign != null && alignItemsStyles[crossAlign],
+ wrap != null && wrapStyles[wrap],
+ ] as const;
+}
diff --git a/packages/core/src/Layout/Stack/stackItem.stylex.ts b/packages/core/src/Layout/Stack/stackItem.stylex.ts
new file mode 100644
index 0000000000..0ff3c0bb73
--- /dev/null
+++ b/packages/core/src/Layout/Stack/stackItem.stylex.ts
@@ -0,0 +1,116 @@
+/**
+ * @file stackItem.stylex.ts
+ * @input Uses @stylexjs/stylex
+ * @output StyleX utility for stack item styling
+ * @position Layout utility; used by XDSStackItem and directly by components
+ *
+ * SYNC: When modified, update /packages/core/src/Layout/README.md
+ */
+
+import * as stylex from '@stylexjs/stylex';
+
+/**
+ * "Resets" the min-width and min-height of the flex item to behave predictably.
+ *
+ * Flex items have an implicit min size of auto, meaning they will never shrink
+ * smaller than their contents. This reset allows items to be constrained by
+ * their flex parent and become scrollable if necessary.
+ */
+const minSizeResetStyles = stylex.create({
+ reset: {
+ minHeight: 0,
+ minWidth: 0,
+ },
+});
+
+const crossAlignSelfStyles = stylex.create({
+ center: {
+ alignSelf: 'center',
+ },
+ end: {
+ alignSelf: 'flex-end',
+ },
+ start: {
+ alignSelf: 'flex-start',
+ },
+ stretch: {
+ alignSelf: 'stretch',
+ },
+});
+
+/**
+ * Cross-alignment options for stack items.
+ * Overrides the default cross-alignment set on the parent stack.
+ */
+export type StackItemCrossAlignSelf = keyof typeof crossAlignSelfStyles;
+
+const sizeStyles = stylex.create({
+ /**
+ * Fill the remaining space inside of the stack.
+ * Will split the space evenly among other items with "fill".
+ */
+ fill: {
+ flexGrow: 1,
+ },
+ /**
+ * Do not grow or shrink within the stack.
+ * Use the intrinsic size of the item.
+ */
+ static: {
+ flexGrow: 0,
+ flexShrink: 0,
+ },
+});
+
+/**
+ * Size options for stack items.
+ * - `static`: Item uses its intrinsic size, won't grow or shrink
+ * - `fill`: Item grows to fill remaining space (flexGrow: 1)
+ */
+export type StackItemSize = keyof typeof sizeStyles;
+
+export interface StackItemOptions {
+ /**
+ * Overrides the default cross-alignment for this item.
+ * (hAlign for VStack, vAlign for HStack)
+ *
+ * Set cross-alignment on the stack itself and override individual
+ * children as needed with this option.
+ */
+ crossAlignSelf?: StackItemCrossAlignSelf;
+
+ /**
+ * Size behavior of the item within the stack.
+ * - `static`: Uses intrinsic size, won't grow or shrink (default)
+ * - `fill`: Grows to fill remaining space
+ *
+ * @default "static"
+ */
+ size?: StackItemSize;
+}
+
+/**
+ * StyleX utility to add stack item styles to any component.
+ *
+ * Use this to avoid wrapping components in XDSStackItem when you need
+ * direct control over flex behavior.
+ *
+ * @example
+ * ```tsx
+ * import { stackItem } from '@xds/core/Layout';
+ *
+ * <div {...stylex.props(...stackItem({ size: 'fill' }))}>
+ * Content that fills remaining space
+ * </div>
+ * ```
+ */
+export function stackItem({
+ crossAlignSelf,
+ size,
+}: StackItemOptions = {}) {
+ return [
+ minSizeResetStyles.reset,
+ sizeStyles[size ?? 'static'],
+ crossAlignSelf != null && crossAlignSelfStyles[crossAlignSelf],
+ ] as const;
+}
diff --git a/packages/core/src/Layout/index.ts b/packages/core/src/Layout/index.ts
new file mode 100644
index 0000000000..fa643063b2
--- /dev/null
+++ b/packages/core/src/Layout/index.ts
@@ -0,0 +1,30 @@
+/**
+ * @file index.ts
+ * @input Imports layout utilities and components from subfolders
+ * @output Exports XDS layout system
+ * @position Entry point for @xds/core/Layout
+ *
+ * SYNC: When modified, update /packages/core/src/Layout/README.md
+ */
+
+// Stack utilities and components
+export {
+ stack,
+ stackItem,
+ XDSHStack,
+ XDSVStack,
+ XDSStackItem,
+} from './Stack';
+export type {
+ StackOptions,
+ StackDirection,
+ StackCrossAlignment,
+ StackWrap,
+ SpacingScale,
+ StackItemOptions,
+ StackItemCrossAlignSelf,
+ StackItemSize,
+ XDSHStackProps,
+ XDSVStackProps,
+ XDSStackItemProps,
+} from './Stack';
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 7576158ba3..9ba4e0fe9c 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -1,6 +1,6 @@
/**
* @file index.ts
- * @input Imports from component directories (Button/)
+ * @input Imports from component directories (Button/, Layout/)
* @output Exports all public components and types for @xds/core
* @position Package entry point; consumed by external applications
*
@@ -10,5 +10,8 @@
// Components
export * from './Button';
+// Layout utilities and components (includes XDSHStack, XDSVStack)
+export * from './Layout';
+
// Theme
export * from './theme';
diff --git a/packages/core/tsup.config.ts b/packages/core/tsup.config.ts
index 45b3cb3343..7c01c7d504 100644
--- a/packages/core/tsup.config.ts
+++ b/packages/core/tsup.config.ts
@@ -11,7 +11,7 @@ import { defineConfig } from 'tsup';
import babel from 'esbuild-plugin-babel';
export default defineConfig({
- entry: ['src/index.ts', 'src/Button/index.ts'],
+ entry: ['src/index.ts', 'src/Button/index.ts', 'src/Layout/index.ts'],
format: ['cjs', 'esm'],
dts: true,
splitting: true,