Skip to content

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

TypeScript

docs(layout): improve descriptions for LLM discoverability (#198)

Cindy Zhanga84b39110536
diff --git a/.gitignore b/.gitignore
index 4991f98329..e86b921ddb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,3 +45,6 @@ internal/vibe-tests/results/
# XDS agent docs (generated)
.xds-docs/
+apps/sandbox/.next/
+apps/sandbox/out/
+apps/sandbox/next-env.d.ts
diff --git a/packages/core/src/Layout/README.md b/packages/core/src/Layout/README.md
index 5e4274dc0e..da104f0d81 100644
--- a/packages/core/src/Layout/README.md
+++ b/packages/core/src/Layout/README.md
@@ -90,20 +90,22 @@ Layout/
</XDSCard>
```
-### Layout with Sidebar
+### App shell with sidebar
```tsx
-<XDSCard>
- <XDSLayout
- header={<XDSLayoutHeader hasDivider>Settings</XDSLayoutHeader>}
- start={
- <XDSLayoutPanel hasDivider role="navigation">
- <Navigation />
- </XDSLayoutPanel>
- }
- content={<XDSLayoutContent>Main content</XDSLayoutContent>}
- />
-</XDSCard>
+<XDSLayout
+ header={<XDSLayoutHeader hasDivider>App Name</XDSLayoutHeader>}
+ start={
+ <XDSLayoutPanel hasDivider width={240} role="navigation">
+ <Navigation />
+ </XDSLayoutPanel>
+ }
+ content={
+ <XDSLayoutContent role="main">
+ <MainContent />
+ </XDSLayoutContent>
+ }
+/>
```
## Components
@@ -120,13 +122,16 @@ See [Container/README.md](./Container/README.md) for full documentation.
### Layout Structure
-| Component | Description |
-| ------------------ | --------------------------------------------------------------- |
-| `XDSLayout` | Arranges content into header, footer, content, start, end slots |
-| `XDSLayoutHeader` | Header content area with optional divider |
-| `XDSLayoutFooter` | Footer content area with optional divider |
-| `XDSLayoutContent` | Scrollable main content area |
-| `XDSLayoutPanel` | Side panel for start/end slots |
+Use XDSLayout for page shells and app layouts — any UI with a header bar, sidebar navigation,
+scrollable content area, or action footer. Don't use for simple stacking (use XDSVStack/XDSHStack).
+
+| Component | Description |
+| ------------------ | ------------------------------------------------------------------------- |
+| `XDSLayout` | Page shell with header, sidebar(s), content, and footer slots |
+| `XDSLayoutHeader` | Top bar — page titles, app bars, toolbars |
+| `XDSLayoutFooter` | Bottom bar — action bars, pagination, status bars |
+| `XDSLayoutContent` | Scrollable main content area |
+| `XDSLayoutPanel` | Sidebar — navigation panels, settings sidebars, detail/inspector panels |
See [XDSLayout/README.md](./XDSLayout/README.md) for full documentation.
diff --git a/packages/core/src/Layout/XDSLayout/README.md b/packages/core/src/Layout/XDSLayout/README.md
index a4eb17e923..ac9cbff8a9 100644
--- a/packages/core/src/Layout/XDSLayout/README.md
+++ b/packages/core/src/Layout/XDSLayout/README.md
@@ -1,12 +1,22 @@
# /packages/core/src/Layout/XDSLayout
-XDS Layout structure components for arranging sections using named slots.
+Page shell and app layout system with header, sidebar, content, and footer slots.
<!-- SYNC: When files in this directory change, update this document. -->
+## When to use
+
+- Building a page with a sidebar → XDSLayout with `start` slot
+- Dashboard with header + scrollable body → XDSLayout with `header` + `content`
+- Settings page with nav panel → XDSLayout with `start` + `content`
+- App shell with top bar, side nav, and main area → XDSLayout with all slots
+- Card with header/body/footer sections → XDSLayout inside XDSCard
+
+Don't use XDSLayout for simple vertical/horizontal stacking — use XDSVStack/XDSHStack instead.
+
## Overview
-The XDSLayout system provides a 5-slot layout structure for building consistent page and component layouts. It follows a **zero styling** principle — no `xstyle` customization props.
+The XDSLayout system provides a 5-slot layout structure for building page shells and structured layouts. It handles padding collapse between adjacent slots, scroll containment, and automatic RTL support. It follows a **zero styling** principle — no `xstyle` customization props.
```
┌─────────────────────────────────────────┐
@@ -36,37 +46,93 @@ import {
## Usage
-XDSLayout must be wrapped in a container component (XDSCard, XDSSection, or XDSLayoutContainer), which provides visual appearance and padding context.
+XDSLayout can be used standalone for page-level layouts, or inside a container
+component (XDSCard, XDSSection) for content-level layouts like cards with
+header/body/footer sections.
-### Basic Layout
+### Full-page app shell with sidebar
```tsx
-<XDSCard>
- <XDSLayout
- header={<XDSLayoutHeader hasDivider>Page Title</XDSLayoutHeader>}
- content={<XDSLayoutContent>Main content here</XDSLayoutContent>}
- footer={<XDSLayoutFooter>Actions</XDSLayoutFooter>}
- />
-</XDSCard>
+<XDSLayout
+ header={<XDSLayoutHeader hasDivider>App Name</XDSLayoutHeader>}
+ start={
+ <XDSLayoutPanel hasDivider width={240} role="navigation">
+ <Navigation />
+ </XDSLayoutPanel>
+ }
+ content={
+ <XDSLayoutContent role="main">
+ <MainContent />
+ </XDSLayoutContent>
+ }
+/>
+```
+
+### App shell with XDSTopNav
+
+XDSLayout slots accept any component — you don't need to wrap in XDSLayoutHeader.
+Components like XDSTopNav that manage their own padding, height, and divider
+can go directly in the `header` slot:
+
+```tsx
+<XDSLayout
+ header={
+ <XDSTopNav
+ label="Main navigation"
+ title={<XDSTopNavTitle title="My App" logo={<Logo />} />}
+ startContent={
+ <>
+ <XDSTopNavItem label="Home" href="/" isSelected />
+ <XDSTopNavItem label="Settings" href="/settings" />
+ </>
+ }
+ endContent={<Avatar />}
+ />
+ }
+ start={
+ <XDSLayoutPanel hasDivider width={240} role="navigation">
+ <SideNav />
+ </XDSLayoutPanel>
+ }
+ content={
+ <XDSLayoutContent role="main">
+ <MainContent />
+ </XDSLayoutContent>
+ }
+/>
+```
+
+Use XDSLayoutHeader when your header is simple content (a heading, buttons, etc.)
+that needs the layout's padding and divider management. Use XDSTopNav or other
+self-contained components directly when they handle their own chrome.
+
+### Dashboard with sidebar and detail panel
+
+```tsx
+<XDSLayout
+ header={<XDSLayoutHeader hasDivider>Dashboard</XDSLayoutHeader>}
+ start={
+ <XDSLayoutPanel hasDivider width={200} role="navigation">
+ <Navigation />
+ </XDSLayoutPanel>
+ }
+ content={<XDSLayoutContent>Main content</XDSLayoutContent>}
+ end={
+ <XDSLayoutPanel hasDivider width={300} role="complementary">
+ <DetailPanel />
+ </XDSLayoutPanel>
+ }
+/>
```
-### With Sidebars
+### Card with structured content
```tsx
<XDSCard>
<XDSLayout
- header={<XDSLayoutHeader hasDivider>Dashboard</XDSLayoutHeader>}
- start={
- <XDSLayoutPanel hasDivider role="navigation">
- <Navigation />
- </XDSLayoutPanel>
- }
- content={<XDSLayoutContent>Main content</XDSLayoutContent>}
- end={
- <XDSLayoutPanel hasDivider role="complementary">
- <Sidebar />
- </XDSLayoutPanel>
- }
+ header={<XDSLayoutHeader hasDivider>Page Title</XDSLayoutHeader>}
+ content={<XDSLayoutContent>Main content here</XDSLayoutContent>}
+ footer={<XDSLayoutFooter hasDivider>Actions</XDSLayoutFooter>}
/>
</XDSCard>
```
@@ -101,13 +167,13 @@ Use `isFullBleed` on XDSLayoutContent to remove internal padding, allowing conte
## Components
-| Component | Description | Renders |
-| ------------------ | -------------------------------------- | --------------------------------- |
-| `XDSLayout` | Main layout component with named slots | `<div>` |
-| `XDSLayoutHeader` | Header content area | `<div>` (use `role` for landmark) |
-| `XDSLayoutFooter` | Footer content area | `<div>` (use `role` for landmark) |
-| `XDSLayoutContent` | Main content area | `<div>` (use `role` for landmark) |
-| `XDSLayoutPanel` | Side panel for start/end slots | `<div>` (use `role` for landmark) |
+| Component | Description | Renders |
+| ------------------ | ------------------------------------------------------------------------- | --------------------------------- |
+| `XDSLayout` | Page shell with header, sidebar(s), content, and footer slots | `<div>` |
+| `XDSLayoutHeader` | Top bar — page titles, app bars, toolbars | `<div>` (use `role` for landmark) |
+| `XDSLayoutFooter` | Bottom bar — action bars, pagination, status bars | `<div>` (use `role` for landmark) |
+| `XDSLayoutContent` | Scrollable main content area | `<div>` (use `role` for landmark) |
+| `XDSLayoutPanel` | Sidebar — navigation panels, settings sidebars, detail/inspector panels | `<div>` (use `role` for landmark) |
## Props
diff --git a/packages/core/src/Layout/XDSLayout/XDSLayout.tsx b/packages/core/src/Layout/XDSLayout/XDSLayout.tsx
index d832f617af..7908362783 100644
--- a/packages/core/src/Layout/XDSLayout/XDSLayout.tsx
+++ b/packages/core/src/Layout/XDSLayout/XDSLayout.tsx
@@ -2,7 +2,10 @@
* @file XDSLayout.tsx
* @input Uses React, stack/stackItem utilities, XDSLayoutAreaContext, XDSLayoutSlotsContext
* @output Exports XDSLayout component and XDSLayoutProps, XDSLayoutHeight types
- * @position Core layout component with named slots
+ * @position Page shell and app layout — use for any page with a header, sidebar, or content area.
+ * Building a page with a sidebar? Use XDSLayout with start/end slots.
+ * Need a header + scrollable content? Use XDSLayout with header + content slots.
+ * Manages padding collapse, scroll containment, and responsive slot sizing automatically.
*
* SYNC: When modified, update these files to stay in sync:
* - /packages/core/src/Layout/XDSLayout/README.md
@@ -113,7 +116,14 @@ function AreaProvider({
}
/**
- * Arranges sections using named slots. Must be wrapped in XDSLayoutContainer.
+ * Page shell with header, sidebar(s), content, and footer slots.
+ * Use this for full-page layouts, app shells, dashboard layouts, or any UI
+ * that needs a header bar, side navigation, scrollable content area, or action footer.
+ * Can be used standalone for page-level layouts, or inside a container
+ * (XDSCard, XDSSection) for content-level layouts.
+ *
+ * Handles padding collapse between adjacent slots, scroll containment in the
+ * content area, and automatic RTL support via CSS logical properties.
*
* Structure:
* ```
@@ -128,14 +138,48 @@ function AreaProvider({
* └─────────────────────────────────────────┘
* ```
*
+ * When to use XDSLayout vs raw flexbox:
+ * - Page with a sidebar → XDSLayout with `start` slot
+ * - Dashboard with header + scrollable body → XDSLayout with `header` + `content`
+ * - Settings page with nav panel → XDSLayout with `start` + `content`
+ * - Simple vertical stack of items → use XDSVStack instead
+ *
* @example
* ```tsx
- * <XDSLayoutContainer variant="card">
+ * // Full-page app shell with sidebar navigation
+ * <XDSLayout
+ * header={<XDSLayoutHeader hasDivider>App Name</XDSLayoutHeader>}
+ * start={
+ * <XDSLayoutPanel hasDivider width={240} role="navigation">
+ * <Navigation />
+ * </XDSLayoutPanel>
+ * }
+ * content={
+ * <XDSLayoutContent role="main">
+ * <MainContent />
+ * </XDSLayoutContent>
+ * }
+ * />
+ *
+ * // With XDSTopNav — no wrapper needed, TopNav manages its own chrome
+ * <XDSLayout
+ * header={
+ * <XDSTopNav
+ * label="Main navigation"
+ * title={<XDSTopNavTitle title="My App" logo={<Logo />} />}
+ * startContent={<XDSTopNavItem label="Home" href="/" isSelected />}
+ * />
+ * }
+ * content={<XDSLayoutContent role="main">...</XDSLayoutContent>}
+ * />
+ *
+ * // Card with structured content
+ * <XDSCard>
* <XDSLayout
- * header={<XDSLayoutHeader>Title</XDSLayoutHeader>}
+ * header={<XDSLayoutHeader hasDivider>Title</XDSLayoutHeader>}
* content={<XDSLayoutContent>Body</XDSLayoutContent>}
* />
- * </XDSLayoutContainer>
+ * </XDSCard>
* ```
*/
export function XDSLayout({
diff --git a/packages/core/src/Layout/XDSLayout/XDSLayoutContent.tsx b/packages/core/src/Layout/XDSLayout/XDSLayoutContent.tsx
index 5cf2bbc149..4cb4e6c1d1 100644
--- a/packages/core/src/Layout/XDSLayout/XDSLayoutContent.tsx
+++ b/packages/core/src/Layout/XDSLayout/XDSLayoutContent.tsx
@@ -2,7 +2,8 @@
* @file XDSLayoutContent.tsx
* @input Uses React forwardRef, StyleX, XDSLayoutSlotsContext
* @output Exports XDSLayoutContent component and XDSLayoutContentProps
- * @position Layout content area component
+ * @position Scrollable main content area for XDSLayout. Wraps the primary body content
+ * with automatic scroll containment and context-aware padding.
*
* SYNC: When modified, update these files to stay in sync:
* - /packages/core/src/Layout/XDSLayout/README.md
@@ -93,8 +94,8 @@ export interface XDSLayoutContentProps extends Omit<
}
/**
- * Main content area for XDSLayout.
- * Renders in the content slot with optional scrollable overflow and padding control.
+ * Scrollable main content area for XDSLayout. Wraps the primary body content
+ * with automatic scroll containment and context-aware padding.
*
* @example
* ```tsx
diff --git a/packages/core/src/Layout/XDSLayout/XDSLayoutFooter.tsx b/packages/core/src/Layout/XDSLayout/XDSLayoutFooter.tsx
index 9604f5c0cf..b2e17ac94b 100644
--- a/packages/core/src/Layout/XDSLayout/XDSLayoutFooter.tsx
+++ b/packages/core/src/Layout/XDSLayout/XDSLayoutFooter.tsx
@@ -2,7 +2,8 @@
* @file XDSLayoutFooter.tsx
* @input Uses React forwardRef, StyleX
* @output Exports XDSLayoutFooter component and XDSLayoutFooterProps
- * @position Layout content area component
+ * @position Bottom bar / footer area for XDSLayout. Use for action bars,
+ * pagination, status bars, or any fixed-height content at the bottom of a layout.
*
* SYNC: When modified, update these files to stay in sync:
* - /packages/core/src/Layout/XDSLayout/README.md
@@ -90,7 +91,7 @@ export interface XDSLayoutFooterProps extends Omit<
}
/**
- * Footer content area for XDSLayout.
+ * Bottom bar / footer for XDSLayout. Use for action bars, pagination, or status bars.
* Renders in the footer slot with optional divider and padding control.
*
* @example
diff --git a/packages/core/src/Layout/XDSLayout/XDSLayoutHeader.tsx b/packages/core/src/Layout/XDSLayout/XDSLayoutHeader.tsx
index dd2fe05cb3..ab88a462f3 100644
--- a/packages/core/src/Layout/XDSLayout/XDSLayoutHeader.tsx
+++ b/packages/core/src/Layout/XDSLayout/XDSLayoutHeader.tsx
@@ -2,7 +2,8 @@
* @file XDSLayoutHeader.tsx
* @input Uses React forwardRef, StyleX
* @output Exports XDSLayoutHeader component and XDSLayoutHeaderProps
- * @position Layout content area component
+ * @position Top bar / header area for XDSLayout. Use for page titles, app bars,
+ * toolbar areas, or any fixed-height content at the top of a layout.
*
* SYNC: When modified, update these files to stay in sync:
* - /packages/core/src/Layout/XDSLayout/README.md
@@ -90,7 +91,7 @@ export interface XDSLayoutHeaderProps extends Omit<
}
/**
- * Header content area for XDSLayout.
+ * Top bar / header for XDSLayout. Use for page titles, app bars, or toolbars.
* Renders in the header slot with optional divider and padding control.
*
* @example
diff --git a/packages/core/src/Layout/XDSLayout/XDSLayoutPanel.tsx b/packages/core/src/Layout/XDSLayout/XDSLayoutPanel.tsx
index 3f1fe6a08a..b0def9ead6 100644
--- a/packages/core/src/Layout/XDSLayout/XDSLayoutPanel.tsx
+++ b/packages/core/src/Layout/XDSLayout/XDSLayoutPanel.tsx
@@ -2,7 +2,8 @@
* @file XDSLayoutPanel.tsx
* @input Uses React forwardRef, StyleX, XDSLayoutAreaContext, XDSLayoutSlotsContext
* @output Exports XDSLayoutPanel component and XDSLayoutPanelProps
- * @position Layout content area component
+ * @position Sidebar panel for XDSLayout start/end slots. Use for navigation panels,
+ * settings sidebars, detail panels, or any fixed-width side content.
*
* SYNC: When modified, update these files to stay in sync:
* - /packages/core/src/Layout/XDSLayout/README.md
@@ -134,8 +135,9 @@ export interface XDSLayoutPanelProps extends Omit<
}
/**
- * Side panel content area for XDSLayout.
- * Renders in the start or end slot with optional divider and padding control.
+ * Sidebar or side panel for XDSLayout. Use in the `start` slot for left navigation
+ * or in the `end` slot for detail/inspector panels.
+ * Renders with optional divider and context-aware padding.
* Divider position is auto-detected based on which slot the panel is in.
*
* @example
diff --git a/packages/core/src/TopNav/README.md b/packages/core/src/TopNav/README.md
index 112fce043f..8cb96616a7 100644
--- a/packages/core/src/TopNav/README.md
+++ b/packages/core/src/TopNav/README.md
@@ -113,6 +113,37 @@ import {HomeIcon, BellIcon, UserCircleIcon} from '@heroicons/react/24/outline';
## Layout Structure
+XDSTopNav works directly in XDSLayout's `header` slot — no XDSLayoutHeader
+wrapper needed. TopNav manages its own padding, height, and divider.
+
+```tsx
+import {XDSLayout, XDSLayoutContent, XDSLayoutPanel} from '@xds/core/Layout';
+import {XDSTopNav, XDSTopNavTitle, XDSTopNavItem} from '@xds/core/TopNav';
+
+<XDSLayout
+ header={
+ <XDSTopNav
+ label="Main navigation"
+ title={<XDSTopNavTitle title="My App" logo={<Logo />} />}
+ startContent={
+ <>
+ <XDSTopNavItem label="Home" href="/" isSelected />
+ <XDSTopNavItem label="Settings" href="/settings" />
+ </>
+ }
+ endContent={<Avatar />}
+ />
+ }
+ content={
+ <XDSLayoutContent role="main">
+ <MainContent />
+ </XDSLayoutContent>
+ }
+/>
+```
+
+## Slot Layout Structure
+
```
┌─────────────────────────────────────────────────────────────┐
│ [title] [startContent ...] [...endContent] │