Skip to content

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

TypeScript

feat(docsite): shell, navigation, and route structure (#1951)

Cindy Zhang54666a53ca39
diff --git a/apps/docsite/package.json b/apps/docsite/package.json
index 4ffa6a4425..dd8da82afc 100644
--- a/apps/docsite/package.json
+++ b/apps/docsite/package.json
@@ -9,6 +9,7 @@
"prebuild": "node scripts/generate-data.mjs",
"build": "next build",
"start": "next start",
+ "typecheck": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest"
},
diff --git a/apps/docsite/scripts/generate-data.mjs b/apps/docsite/scripts/generate-data.mjs
index 6c1f376e56..77f048d71b 100644
--- a/apps/docsite/scripts/generate-data.mjs
+++ b/apps/docsite/scripts/generate-data.mjs
@@ -131,6 +131,9 @@ function generatePackageRegistry() {
const hasReadme = fs.existsSync(path.join(REPO_ROOT, dir, 'README.md'));
const hasChangelog = fs.existsSync(path.join(REPO_ROOT, dir, 'CHANGELOG.md'));
+ const readme = hasReadme
+ ? fs.readFileSync(path.join(REPO_ROOT, dir, 'README.md'), 'utf-8')
+ : null;
return {
name: raw.name,
displayName: raw.displayName || raw.name.replace('@xds/', '').replace('theme-', 'Theme: ').replace(/^\w/, c => c.toUpperCase()),
@@ -139,6 +142,7 @@ function generatePackageRegistry() {
packagePath: dir,
hasReadme,
hasChangelog,
+ readme,
};
})
.filter(Boolean)
@@ -154,6 +158,7 @@ export interface PackageMeta {
packagePath: string;
hasReadme: boolean;
hasChangelog: boolean;
+ readme: string | null;
}
export const packages: PackageMeta[] = ${JSON.stringify(packages, null, 2)};
@@ -227,7 +232,7 @@ async function generateComponentRegistry() {
if (!subName) continue;
pendingSubComponents.push({
name: subName,
- displayName: sub.name || subName,
+ moduleName: sub.name || subName,
directory: entry.name,
group,
description: sub.description || topDescription,
@@ -242,7 +247,7 @@ async function generateComponentRegistry() {
standaloneNames.add(name);
components.push({
name,
- displayName: name.startsWith('use') ? name : `XDS${name}`,
+ moduleName: name.startsWith('use') ? name : `XDS${name}`,
directory: entry.name,
group,
description: topDescription,
@@ -274,8 +279,8 @@ async function generateComponentRegistry() {
export interface ComponentEntry {
/** Component name without XDS prefix (e.g. 'Button', 'TableRow', 'useClickableContainer') */
name: string;
- /** Full display name (e.g. 'XDSButton', 'XDSTableRow', 'useClickableContainer') */
- displayName: string;
+ /** Actual exported module name (e.g. 'XDSButton', 'XDSTableRow', 'useClickableContainer') */
+ moduleName: string;
/** Source directory containing this component (e.g. 'Button', 'hooks', 'Table') */
directory: string;
/** Sidebar group from docs.group (e.g. 'Actions', 'Chat', 'Table') */
@@ -452,16 +457,18 @@ async function generateDocsRegistry() {
let title = '';
let description = '';
+ let category = '';
try {
const mod = await import(`file://${docPath}`);
title = mod.docs?.title || '';
description = mod.docs?.description || '';
+ category = mod.docs?.category || '';
} catch {
const meta = readDocMeta(docPath);
description = meta.description;
}
- docTopics.push({topic, title: title || topic, description});
+ docTopics.push({topic, title: title || topic, description, category: category || null});
}
docTopics.sort((a, b) => a.topic.localeCompare(b.topic));
@@ -475,6 +482,8 @@ export interface DocTopic {
title: string;
/** Short description */
description: string;
+ /** Navigation category: 'guide' | 'foundations' | null */
+ category: string | null;
}
export const docTopics: DocTopic[] = ${JSON.stringify(docTopics, null, 2)};
diff --git a/apps/docsite/src/__tests__/data-extraction.test.ts b/apps/docsite/src/__tests__/data-extraction.test.ts
index bf24574aa3..f62710a0b7 100644
--- a/apps/docsite/src/__tests__/data-extraction.test.ts
+++ b/apps/docsite/src/__tests__/data-extraction.test.ts
@@ -42,6 +42,24 @@ describe('packageRegistry', () => {
const names = packages.map(p => p.name);
expect(new Set(names).size).toBe(names.length);
});
+
+ it('packages with READMEs have readme content', () => {
+ for (const pkg of packages) {
+ if (pkg.hasReadme) {
+ expect(pkg.readme).toBeTruthy();
+ expect(typeof pkg.readme).toBe('string');
+ expect(pkg.readme!.length).toBeGreaterThan(50);
+ } else {
+ expect(pkg.readme).toBeNull();
+ }
+ }
+ });
+
+ it('CLI package has a substantial README', () => {
+ const cli = packages.find(p => p.name === '@xds/cli');
+ expect(cli?.readme).toBeTruthy();
+ expect(cli!.readme!.length).toBeGreaterThan(1000);
+ });
});
// ── Component Registry ─────────────────────────────────────────────────
@@ -65,7 +83,7 @@ describe('componentRegistry', () => {
expect(pkgName).toMatch(/^@xds\//);
for (const comp of comps) {
expect(comp.name).toBeTruthy();
- expect(comp.displayName).toBeTruthy();
+ expect(comp.moduleName).toBeTruthy();
expect(typeof comp.directory).toBe('string');
expect(typeof comp.description).toBe('string');
expect(Array.isArray(comp.keywords)).toBe(true);
@@ -136,18 +154,18 @@ describe('componentRegistry', () => {
expect(button!.parentDoc).toBeNull();
});
- it('displayName has XDS prefix for components, not for hooks', () => {
+ it('moduleName has XDS prefix for components, not for hooks', () => {
const core = components['@xds/core'];
const button = core.find(c => c.name === 'Button');
- expect(button?.displayName).toBe('XDSButton');
+ expect(button?.moduleName).toBe('XDSButton');
const hookComp = core.find(c => c.name === 'useClickableContainer');
- expect(hookComp?.displayName).toBe('useClickableContainer');
+ expect(hookComp?.moduleName).toBe('useClickableContainer');
// Sub-component hooks also keep their name
const tableHook = core.find(c => c.name === 'useXDSTableSelection');
if (tableHook) {
- expect(tableHook.displayName).toMatch(/^use/);
+ expect(tableHook.moduleName).toMatch(/^use/);
}
});
@@ -321,6 +339,16 @@ describe('docsRegistry', () => {
expect(topics).toContain('color');
});
+ it('doc topics have category (guide or foundations)', () => {
+ for (const d of docTopics) {
+ expect(d.category === 'guide' || d.category === 'foundations').toBe(true);
+ }
+ const guide = docTopics.filter(d => d.category === 'guide');
+ const foundations = docTopics.filter(d => d.category === 'foundations');
+ expect(guide.length).toBeGreaterThanOrEqual(4);
+ expect(foundations.length).toBeGreaterThanOrEqual(7);
+ });
+
it('no duplicate topics', () => {
const topics = docTopics.map(d => d.topic);
expect(new Set(topics).size).toBe(topics.length);
diff --git a/apps/docsite/src/app/changelog/page.tsx b/apps/docsite/src/app/changelog/page.tsx
new file mode 100644
index 0000000000..7ae83f1956
--- /dev/null
+++ b/apps/docsite/src/app/changelog/page.tsx
@@ -0,0 +1,23 @@
+/**
+ * Page type: changelog
+ * Version history from CHANGELOG.md files across packages.
+ * TODO: port generate-changelog.js into the data pipeline.
+ */
+
+import {XDSHeading, XDSText} from '@xds/core/Text';
+import {XDSVStack} from '@xds/core/Layout';
+import {XDSSection} from '@xds/core/Section';
+
+export default function ChangelogPage() {
+ return (
+ <XDSSection maxWidth="md" padding={6}>
+ <XDSVStack gap={4}>
+ <XDSHeading level={1}>Changelog</XDSHeading>
+ <XDSText type="body" color="secondary">
+ Version history coming soon.
+ </XDSText>
+ {/* TODO: render from changelogRegistry once ported to pipeline */}
+ </XDSVStack>
+ </XDSSection>
+ );
+}
diff --git a/apps/docsite/src/app/components/[name]/page.tsx b/apps/docsite/src/app/components/[name]/page.tsx
new file mode 100644
index 0000000000..2b176be373
--- /dev/null
+++ b/apps/docsite/src/app/components/[name]/page.tsx
@@ -0,0 +1,97 @@
+/**
+ * Page type: component
+ * Component or hook/utility detail page. Adapts based on content:
+ * - Visual components: showcase + props + anatomy + examples
+ * - Hooks/utilities: params + usage (no showcase if none exists)
+ * - Compound components: also lists sub-components
+ *
+ * All data comes from componentRegistry. Sub-components (parentDoc != null)
+ * are shown on their parent's page, not as standalone routes.
+ */
+
+import {notFound} from 'next/navigation';
+import {XDSHeading, XDSText} from '@xds/core/Text';
+import {XDSVStack, XDSHStack} from '@xds/core/Layout';
+import {XDSSection} from '@xds/core/Section';
+import {XDSCard} from '@xds/core/Card';
+import {XDSBadge} from '@xds/core/Badge';
+import {XDSDivider} from '@xds/core';
+import {components} from '../../../generated/componentRegistry';
+
+const allComponents = Object.values(components).flat();
+
+export function generateStaticParams() {
+ // Generate routes for top-level components only.
+ // Sub-components are rendered on their parent's page.
+ return allComponents.filter(c => !c.parentDoc).map(c => ({name: c.name}));
+}
+
+export default async function ComponentPage({
+ params,
+}: {
+ params: Promise<{name: string}>;
+}) {
+ const {name} = await params;
+ const comp = allComponents.find(c => c.name === name);
+ if (!comp) notFound();
+
+ const subComponents = allComponents.filter(c => c.parentDoc === name);
+ const pkg = Object.entries(components).find(([, comps]) =>
+ comps.includes(comp),
+ )?.[0];
+
+ return (
+ <XDSSection maxWidth="md" padding={6}>
+ <XDSVStack gap={6}>
+ {/* Header */}
+ <XDSVStack gap={2}>
+ <XDSText type="supporting" color="secondary" weight="bold">
+ {comp.moduleName}
+ </XDSText>
+ <XDSHeading level={1}>{comp.name}</XDSHeading>
+ <XDSText type="body" color="secondary">
+ {comp.description}
+ </XDSText>
+ <XDSHStack gap={2}>
+ {comp.group && <XDSBadge label={comp.group} />}
+ {pkg && <XDSBadge label={pkg} variant="info" />}
+ </XDSHStack>
+ </XDSVStack>
+
+ {/* TODO: showcase section — render if blockRegistry has a showcase for this component */}
+
+ {/* TODO: props table — render from pipeline data */}
+
+ {/* TODO: anatomy — render if doc has anatomy data */}
+
+ {/* TODO: examples — render from blockRegistry matches */}
+
+ {/* Sub-components */}
+ {subComponents.length > 0 && (
+ <>
+ <XDSDivider />
+ <XDSVStack gap={4}>
+ <XDSHeading level={2}>
+ Sub-components ({subComponents.length})
+ </XDSHeading>
+ <XDSVStack gap={3}>
+ {subComponents.map(sub => (
+ <XDSCard key={sub.name} padding={4}>
+ <XDSVStack gap={1}>
+ <XDSText type="body" weight="bold">
+ {sub.moduleName}
+ </XDSText>
+ <XDSText type="supporting" color="secondary">
+ {sub.description}
+ </XDSText>
+ </XDSVStack>
+ </XDSCard>
+ ))}
+ </XDSVStack>
+ </XDSVStack>
+ </>
+ )}
+ </XDSVStack>
+ </XDSSection>
+ );
+}
diff --git a/apps/docsite/src/app/docs/[topic]/page.tsx b/apps/docsite/src/app/docs/[topic]/page.tsx
new file mode 100644
index 0000000000..c16704cfd2
--- /dev/null
+++ b/apps/docsite/src/app/docs/[topic]/page.tsx
@@ -0,0 +1,38 @@
+/**
+ * Page type: long-form-doc
+ * Renders documentation topics from CLI docs/*.doc.mjs.
+ * Used for: getting-started, typography, color, spacing, shape, icons,
+ * elevation, motion, principles, styling, tokens, theme.
+ */
+
+import {notFound} from 'next/navigation';
+import {XDSHeading, XDSText} from '@xds/core/Text';
+import {XDSVStack} from '@xds/core/Layout';
+import {XDSSection} from '@xds/core/Section';
+import {docTopics} from '../../../generated/docsRegistry';
+
+export function generateStaticParams() {
+ return docTopics.map(d => ({topic: d.topic}));
+}
+
+export default async function DocPage({
+ params,
+}: {
+ params: Promise<{topic: string}>;
+}) {
+ const {topic: slug} = await params;
+ const topic = docTopics.find(d => d.topic === slug);
+ if (!topic) notFound();
+
+ return (
+ <XDSSection maxWidth="md" padding={6}>
+ <XDSVStack gap={4}>
+ <XDSHeading level={1}>{topic.title}</XDSHeading>
+ <XDSText type="body" color="secondary">
+ {topic.description}
+ </XDSText>
+ {/* TODO: render full doc sections from pipeline */}
+ </XDSVStack>
+ </XDSSection>
+ );
+}
diff --git a/apps/docsite/src/app/layout.tsx b/apps/docsite/src/app/layout.tsx
index d787ecc70c..4affb9f972 100644
--- a/apps/docsite/src/app/layout.tsx
+++ b/apps/docsite/src/app/layout.tsx
@@ -1,17 +1,29 @@
import type {Metadata} from 'next';
import './globals.css';
import {Providers} from './providers';
+import {DocsShell} from '../components/DocsShell';
+import {components} from '../generated/componentRegistry';
+import {packages} from '../generated/packageRegistry';
+import {docTopics} from '../generated/docsRegistry';
export const metadata: Metadata = {
title: 'XDS — Design System',
- description: 'Documentation for the XDS design system',
+ description:
+ 'Open-source design system for building internal tools and products.',
};
export default function RootLayout({children}: {children: React.ReactNode}) {
return (
<html lang="en">
<body>
- <Providers>{children}</Providers>
+ <Providers>
+ <DocsShell
+ components={components}
+ packages={packages}
+ docTopics={docTopics}>
+ {children}
+ </DocsShell>
+ </Providers>
</body>
</html>
);
diff --git a/apps/docsite/src/app/packages/[name]/page.tsx b/apps/docsite/src/app/packages/[name]/page.tsx
new file mode 100644
index 0000000000..de80bff1c5
--- /dev/null
+++ b/apps/docsite/src/app/packages/[name]/page.tsx
@@ -0,0 +1,141 @@
+/**
+ * Page type: package
+ * Adapts based on the package type:
+ * - component-pkg (@xds/core): component grid from componentRegistry
+ * - theme-pkg (@xds/theme-*): theme preview + token info (stub)
+ * - generic (@xds/cli, etc.): README rendered via XDSMarkdown
+ */
+
+import {notFound} from 'next/navigation';
+import {XDSHeading, XDSText} from '@xds/core/Text';
+import {XDSVStack, XDSHStack} from '@xds/core/Layout';
+import {XDSSection} from '@xds/core/Section';
+import {XDSBadge} from '@xds/core/Badge';
+import {XDSGrid} from '@xds/core/Grid';
+import {XDSClickableCard} from '@xds/core/ClickableCard';
+import {XDSMarkdown} from '@xds/core/Markdown';
+import {XDSDivider} from '@xds/core';
+import {packages} from '../../../generated/packageRegistry';
+import {
+ components,
+ type ComponentEntry,
+} from '../../../generated/componentRegistry';
+
+function slugToPackageName(slug: string): string {
+ return `@xds/${slug}`;
+}
+
+export function generateStaticParams() {
+ return packages.map(p => ({name: p.name.replace('@xds/', '')}));
+}
+
+export default async function PackagePage({
+ params,
+}: {
+ params: Promise<{name: string}>;
+}) {
+ const {name: slug} = await params;
+ const pkgName = slugToPackageName(slug);
+ const pkg = packages.find(p => p.name === pkgName);
+ if (!pkg) notFound();
+
+ const isTheme = pkg.name.includes('theme-');
+ const isComponentPkg = pkg.name === '@xds/core';
+ const pkgComponents = components[pkg.name] || [];
+
+ return (
+ <XDSSection maxWidth="lg" padding={6}>
+ <XDSVStack gap={6}>
+ {/* Header — shared across all package types */}
+ <XDSVStack gap={2}>
+ <XDSHeading level={1}>{pkg.displayName}</XDSHeading>
+ <XDSHStack gap={2} vAlign="center">
+ <XDSText type="supporting" color="secondary">
+ {pkg.name}
+ </XDSText>
+ <XDSBadge label={`v${pkg.version}`} variant="info" />
+ </XDSHStack>
+ <XDSText type="body" color="secondary">
+ {pkg.description}
+ </XDSText>
+ </XDSVStack>
+
+ <XDSDivider />
+
+ {/* Content — adapts by package type */}
+ {isComponentPkg ? (
+ <ComponentPackageContent components={pkgComponents} />
+ ) : isTheme ? (
+ <ThemePackageContent />
+ ) : (
+ <GenericPackageContent readme={pkg.readme} />
+ )}
+ </XDSVStack>
+ </XDSSection>
+ );
+}
+
+function ComponentPackageContent({
+ components: pkgComponents,
+}: {
+ components: ComponentEntry[];
+}) {
+ const topLevel = pkgComponents.filter(c => !c.parentDoc);
+
+ if (topLevel.length === 0) {
+ return (
+ <XDSText type="body" color="secondary">
+ No components documented yet.
+ </XDSText>
+ );
+ }
+
+ return (
+ <XDSVStack gap={4}>
+ <XDSHeading level={2}>Components ({topLevel.length})</XDSHeading>
+ <XDSGrid columns={3} gap={4} minChildWidth={200}>
+ {topLevel.map(c => (
+ <XDSClickableCard
+ key={c.name}
+ label={c.name}
+ href={`/components/${c.name}`}
+ padding={4}>
+ <XDSVStack gap={1}>
+ <XDSText type="body" weight="bold">
+ {c.name}
+ </XDSText>
+ {c.group && <XDSBadge label={c.group} />}
+ <XDSText type="supporting" color="secondary">
+ {c.description.slice(0, 100)}
+ {c.description.length > 100 ? '…' : ''}
+ </XDSText>
+ </XDSVStack>
+ </XDSClickableCard>
+ ))}
+ </XDSGrid>
+ </XDSVStack>
+ );
+}
+
+function ThemePackageContent() {
+ return (
+ <XDSVStack gap={4}>
+ {/* TODO: theme preview, token values, setup code from pipeline */}
+ <XDSText type="body" color="secondary">
+ Theme details coming soon.
+ </XDSText>
+ </XDSVStack>
+ );
+}
+
+function GenericPackageContent({readme}: {readme: string | null}) {
+ if (!readme) {
+ return (
+ <XDSText type="body" color="secondary">
+ No README available.
+ </XDSText>
+ );
+ }
+
+ return <XDSMarkdown>{readme}</XDSMarkdown>;
+}
diff --git a/apps/docsite/src/app/page.tsx b/apps/docsite/src/app/page.tsx
index 873fd65568..54d69765e2 100644
--- a/apps/docsite/src/app/page.tsx
+++ b/apps/docsite/src/app/page.tsx
@@ -1,134 +1,90 @@
-import * as stylex from '@stylexjs/stylex';
+/**
+ * Page type: overview
+ * The home page — stats, package cards, quick links.
+ */
+
+import {XDSHeading, XDSText} from '@xds/core/Text';
+import {XDSVStack, XDSHStack} from '@xds/core/Layout';
+import {XDSCard} from '@xds/core/Card';
+import {XDSClickableCard} from '@xds/core/ClickableCard';
+import {XDSGrid} from '@xds/core/Grid';
+import {XDSSection} from '@xds/core/Section';
+import {XDSButton} from '@xds/core/Button';
+import {XDSBadge} from '@xds/core/Badge';
import {packages} from '../generated/packageRegistry';
-import {components, componentCount} from '../generated/componentRegistry';
+import {componentCount} from '../generated/componentRegistry';
import {blockCount, showcaseCount} from '../generated/blockRegistry';
import {templateCount} from '../generated/templateRegistry';
-import {docsCount} from '../generated/docsRegistry';
-
-const styles = stylex.create({
- main: {
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- minHeight: '100vh',
- padding: '2rem',
- },
- container: {
- maxWidth: 640,
- width: '100%',
- },
- heading: {
- fontSize: '2.5rem',
- fontWeight: 700,
- marginBottom: '0.5rem',
- },
- subtitle: {
- fontSize: '1.125rem',
- opacity: 0.7,
- marginBottom: '2rem',
- },
- grid: {
- display: 'grid',
- gridTemplateColumns: 'repeat(auto-fit, minmax(140px, 1fr))',
- gap: '1rem',
- marginBottom: '2rem',
- },
- stat: {
- padding: '1rem',
- borderRadius: 8,
- border: '1px solid var(--color-border)',
- textAlign: 'center' as const,
- },
- statNumber: {
- fontSize: '2rem',
- fontWeight: 700,
- lineHeight: 1,
- },
- statLabel: {
- fontSize: '0.75rem',
- opacity: 0.6,
- marginTop: '0.25rem',
- },
- section: {
- marginBottom: '1.5rem',
- },
- sectionHeading: {
- fontSize: '0.875rem',
- fontWeight: 600,
- opacity: 0.5,
- textTransform: 'uppercase' as const,
- letterSpacing: '0.05em',
- marginBottom: '0.5rem',
- },
- packageList: {
- display: 'flex',
- flexWrap: 'wrap' as const,
- gap: '0.5rem',
- },
- chip: {
- fontSize: '0.8125rem',
- padding: '0.25rem 0.75rem',
- borderRadius: 999,
- border: '1px solid var(--color-border)',
- },
-});
-
-const themeCount = packages.filter(p => p.name.includes('theme-')).length;
-const componentPackages = Object.keys(components);
-export default function Home() {
+export default function HomePage() {
return (
- <main {...stylex.props(styles.main)}>
- <div {...stylex.props(styles.container)}>
- <h1 {...stylex.props(styles.heading)}>XDS</h1>
- <p {...stylex.props(styles.subtitle)}>
- Open-source design system for building internal tools and products.
- </p>
+ <XDSSection maxWidth="lg" padding={6}>
+ <XDSVStack gap={8}>
+ <XDSVStack gap={3}>
+ <XDSHeading level={1}>XDS</XDSHeading>
+ <XDSText type="large" color="secondary">
+ Open-source design system for building internal tools and products.
+ </XDSText>
+ <XDSHStack gap={3}>
+ <XDSButton
+ label="Getting Started"
+ variant="primary"
+ href="/docs/getting-started"
+ />
+ <XDSButton
+ label="Components"
+ variant="secondary"
+ href="/packages/core"
+ />
+ <XDSButton label="Changelog" variant="ghost" href="/changelog" />
+ </XDSHStack>
+ </XDSVStack>
- <div {...stylex.props(styles.grid)}>
- <Stat n={componentCount} label="Components" />
- <Stat n={blockCount} label="Blocks" />
- <Stat n={showcaseCount} label="Showcases" />
- <Stat n={templateCount} label="Templates" />
- <Stat n={themeCount} label="Themes" />
- <Stat n={docsCount} label="Doc Topics" />
- <Stat n={packages.length} label="Packages" />
- <Stat n={componentPackages.length} label="Component Pkgs" />
- </div>
+ <XDSGrid columns={4} gap={4} minChildWidth={140}>
+ <StatCard n={componentCount} label="Components" />
+ <StatCard n={blockCount} label="Blocks" />
+ <StatCard n={showcaseCount} label="Showcases" />
+ <StatCard n={templateCount} label="Templates" />
+ </XDSGrid>
- <div {...stylex.props(styles.section)}>
- <div {...stylex.props(styles.sectionHeading)}>Packages</div>
- <div {...stylex.props(styles.packageList)}>
+ <XDSVStack gap={4}>
+ <XDSHeading level={2}>Packages</XDSHeading>
+ <XDSGrid columns={2} gap={4} minChildWidth={280}>
{packages.map(p => (
- <span key={p.name} {...stylex.props(styles.chip)}>
- {p.name} <span style={{opacity: 0.5}}>v{p.version}</span>
- </span>
- ))}
- </div>
- </div>
-
- <div {...stylex.props(styles.section)}>
- <div {...stylex.props(styles.sectionHeading)}>
- Components by Package
- </div>
- <div {...stylex.props(styles.packageList)}>
- {componentPackages.map(pkg => (
- <span key={pkg} {...stylex.props(styles.chip)}>
- {pkg.replace('@xds/', '')} ({components[pkg].length})
- </span>
+ <XDSClickableCard
+ key={p.name}
+ label={p.name}
+ href={`/packages/${p.name.replace('@xds/', '')}`}
+ padding={5}>
+ <XDSVStack gap={2}>
+ <XDSHStack gap={2} vAlign="center">
+ <XDSText type="body" weight="bold">
+ {p.name}
+ </XDSText>
+ <XDSBadge label={`v${p.version}`} variant="info" />
+ </XDSHStack>
+ <XDSText type="supporting" color="secondary">
+ {p.description}
+ </XDSText>
+ </XDSVStack>
+ </XDSClickableCard>
))}
- </div>
- </div>
- </div>
- </main>
+ </XDSGrid>
+ </XDSVStack>
+ </XDSVStack>
+ </XDSSection>
);
}
-function Stat({n, label}: {n: number; label: string}) {
+function StatCard({n, label}: {n: number; label: string}) {
return (
- <div {...stylex.props(styles.stat)}>
- <div {...stylex.props(styles.statNumber)}>{n}</div>
- <div {...stylex.props(styles.statLabel)}>{label}</div>
- </div>
+ <XDSCard padding={4}>
+ <XDSVStack gap={1} hAlign="center">
+ <XDSText type="display-2">{n}</XDSText>
+ <XDSText type="supporting" color="secondary">
+ {label}
+ </XDSText>
+ </XDSVStack>
+ </XDSCard>
);
}
diff --git a/apps/docsite/src/components/DocsShell.tsx b/apps/docsite/src/components/DocsShell.tsx
new file mode 100644
index 0000000000..51075a8db9
--- /dev/null
+++ b/apps/docsite/src/components/DocsShell.tsx
@@ -0,0 +1,345 @@
+'use client';
+
+import {usePathname} from 'next/navigation';
+import {XDSAppShell} from '@xds/core/AppShell';
+import {XDSTopNav, XDSTopNavHeading} from '@xds/core/TopNav';
+import {XDSSideNav, XDSSideNavItem, XDSSideNavSection} from '@xds/core/SideNav';
+import {XDSButton} from '@xds/core/Button';
+import {XDSLink} from '@xds/core/Link';
+import {XDSVStack} from '@xds/core/Layout';
+import type {ComponentEntry} from '../generated/componentRegistry';
+import type {PackageMeta} from '../generated/packageRegistry';
+import type {DocTopic} from '../generated/docsRegistry';
+
+interface DocsShellProps {
+ children: React.ReactNode;
+ components: Record<string, ComponentEntry[]>;
+ packages: PackageMeta[];
+ docTopics: DocTopic[];
+}
+
+/** Foundations: tokens first, then alphabetical */
+const foundationsSort = (a: DocTopic, b: DocTopic) => {
+ if (a.topic === 'tokens') return -1;
+ if (b.topic === 'tokens') return 1;
+ return a.title.localeCompare(b.title);
+};
+
+// ── Component sidebar builder ──────────────────────────────────────────
+
+type SidebarItem =
+ | {type: 'entry'; name: string; href: string}
+ | {
+ type: 'group';
+ label: string;
+ entries: Array<{name: string; href: string}>;
+ };
+
+function buildComponentSidebar(entries: ComponentEntry[]): {
+ componentItems: SidebarItem[];
+ utilities: Array<{name: string; href: string}>;
+} {
+ const utilities: Array<{name: string; href: string}> = [];
+ const groups = new Map<string, Array<{name: string; href: string}>>();
+ const ungrouped: Array<{name: string; href: string}> = [];
+
+ const parentDocsWithComponents = new Set<string>();
+ for (const e of entries) {
+ if (e.parentDoc && !e.name.startsWith('use') && !e.hidden) {
+ parentDocsWithComponents.add(e.parentDoc);
+ }
+ }
+
+ for (const entry of entries) {
+ if (entry.hidden) continue;
+ const isHook = entry.name.startsWith('use');
+
+ if (
+ entry.group === 'Utilities' ||
+ (isHook && !entry.parentDoc && entry.directory === 'hooks')
+ ) {
+ utilities.push({name: entry.name, href: `/components/${entry.name}`});
+ continue;
+ }
+ if (entry.group) {
+ if (!groups.has(entry.group)) groups.set(entry.group, []);
+ groups
+ .get(entry.group)!
+ .push({name: entry.name, href: `/components/${entry.name}`});
+ continue;
+ }
+ if (isHook && !entry.parentDoc && entry.directory !== 'hooks') {
+ const dir = entry.directory;
+ if (!groups.has(dir)) groups.set(dir, []);
+ groups
+ .get(dir)!
+ .push({name: entry.name, href: `/components/${entry.name}`});
+ continue;
+ }
+ if (
+ isHook &&
+ entry.parentDoc &&
+ parentDocsWithComponents.has(entry.parentDoc)
+ ) {
+ const parent = entry.parentDoc;
+ if (!groups.has(parent)) groups.set(parent, []);
+ groups
+ .get(parent)!
+ .push({name: entry.name, href: `/components/${entry.name}`});
+ continue;
+ }
+ if (isHook) {
+ utilities.push({name: entry.name, href: `/components/${entry.name}`});
+ continue;
+ }
+ ungrouped.push({name: entry.name, href: `/components/${entry.name}`});
+ }
+
+ const items: Array<{sortKey: string; item: SidebarItem}> = [];
+ for (const [label, members] of groups) {
+ members.sort((a, b) => a.name.localeCompare(b.name));
+ if (members.length === 1) {
+ items.push({
+ sortKey: members[0].name,
+ item: {type: 'entry', ...members[0]},
+ });
+ } else {
+ items.push({
+ sortKey: label,
+ item: {type: 'group', label, entries: members},
+ });
+ }
+ }
+ for (const entry of ungrouped) {
+ items.push({sortKey: entry.name, item: {type: 'entry', ...entry}});
+ }
+ items.sort((a, b) => a.sortKey.localeCompare(b.sortKey));
+
+ return {
+ componentItems: items.map(i => i.item),
+ utilities: utilities.sort((a, b) => a.name.localeCompare(b.name)),
+ };
+}
+
+// ── Shell ──────────────────────────────────────────────────────────────
+
+export function DocsShell({
+ children,
+ components,
+ packages,
+ docTopics,
+}: DocsShellProps) {
+ const pathname = usePathname();
+
+ const coreComponents = components['@xds/core'] || [];
+ const {componentItems, utilities} = buildComponentSidebar(coreComponents);
+
+ // Classify packages
+ const isTheme = (p: PackageMeta) => p.name.includes('theme-');
+ const themePackages = packages.filter(isTheme);
+ const libraryPackages = packages.filter(p => !isTheme(p));
+
+ // Classify doc topics by category (from data)
+ const guideTopics = docTopics
+ .filter(d => d.category === 'guide')
+ .sort((a, b) => a.title.localeCompare(b.title));
+ const foundationTopics = docTopics
+ .filter(d => d.category === 'foundations')
+ .sort(foundationsSort);
+
+ // Active state detection
+ const allComponentHrefs = componentItems.flatMap(item =>
+ item.type === 'entry' ? [item.href] : item.entries.map(e => e.href),
+ );
+ const isInGuide =
+ guideTopics.some(d => pathname === `/docs/${d.topic}`) ||
+ foundationTopics.some(d => pathname === `/docs/${d.topic}`);
+ const isInFoundations = foundationTopics.some(
+ d => pathname === `/docs/${d.topic}`,
+ );
+ const isInLibraries = libraryPackages.some(
+ p => pathname === `/packages/${p.name.replace('@xds/', '')}`,
+ );
+ const isInThemes = themePackages.some(
+ p => pathname === `/packages/${p.name.replace('@xds/', '')}`,
+ );
+ const isInComponents = allComponentHrefs.includes(pathname);
+ const isInUtilities = utilities.some(u => pathname === u.href);
+
+ return (
+ <XDSAppShell
+ variant="surface"
+ height="fill"
+ mobileNav={{breakpoint: 'none'}}
+ topNav={
+ <XDSTopNav
+ label="XDS navigation"
+ heading={<XDSTopNavHeading logo="XDS" headingHref="/" />}
+ endContent={
+ <XDSButton
+ label="GitHub"
+ variant="ghost"
+ href="https://github.com/facebookexperimental/xds"
+ />
+ }
+ />
+ }
+ sideNav={
+ <XDSSideNav
+ footer={
+ <XDSVStack gap={1}>
+ <XDSLink
+ label="Terms of Use"
+ href="https://opensource.fb.com/legal/terms"
+ isExternalLink>
+ Terms of Use
+ </XDSLink>
+ <XDSLink
+ label="Privacy Policy"
+ href="https://opensource.fb.com/legal/privacy"
+ isExternalLink>
+ Privacy Policy
+ </XDSLink>
+ </XDSVStack>
+ }>
+ {/* Home */}
+ <XDSSideNavSection title="Home" isHeaderHidden>
+ <XDSSideNavItem
+ label="Home"
+ href="/"
+ isSelected={pathname === '/'}
+ />
+ </XDSSideNavSection>
+
+ {/* What's New */}
+ <XDSSideNavSection title="Changelog" isHeaderHidden>
+ <XDSSideNavItem
+ label="What's New"
+ href="/changelog"
+ isSelected={pathname === '/changelog'}
+ />
+ </XDSSideNavSection>
+
+ {/* Guide */}
+ <XDSSideNavSection title="Guide" isHeaderHidden>
+ <XDSSideNavItem
+ label="Guide"
+ collapsible={{defaultIsCollapsed: !isInGuide}}>
+ {guideTopics.map(d => (
+ <XDSSideNavItem
+ key={d.topic}
+ label={d.title}
+ href={`/docs/${d.topic}`}
+ isSelected={pathname === `/docs/${d.topic}`}
+ />
+ ))}
+ <XDSSideNavItem
+ label="Foundations"
+ collapsible={{defaultIsCollapsed: !isInFoundations}}>
+ {foundationTopics.map(d => (
+ <XDSSideNavItem
+ key={d.topic}
+ label={d.title}
+ href={`/docs/${d.topic}`}
+ isSelected={pathname === `/docs/${d.topic}`}
+ />
+ ))}
+ </XDSSideNavItem>
+ </XDSSideNavItem>
+ </XDSSideNavSection>
+
+ {/* Libraries */}
+ <XDSSideNavSection title="Libraries" isHeaderHidden>
+ <XDSSideNavItem
+ label="Libraries"
+ collapsible={{defaultIsCollapsed: !isInLibraries}}>
+ {libraryPackages.map(p => (
+ <XDSSideNavItem
+ key={p.name}
+ label={p.name}
+ href={`/packages/${p.name.replace('@xds/', '')}`}
+ isSelected={
+ pathname === `/packages/${p.name.replace('@xds/', '')}`
+ }
+ />
+ ))}
+ </XDSSideNavItem>
+ </XDSSideNavSection>
+
+ {/* Themes */}
+ <XDSSideNavSection title="Themes" isHeaderHidden>
+ <XDSSideNavItem
+ label="Themes"
+ collapsible={{defaultIsCollapsed: !isInThemes}}>
+ {themePackages.map(p => (
+ <XDSSideNavItem
+ key={p.name}
+ label={p.displayName}
+ href={`/packages/${p.name.replace('@xds/', '')}`}
+ isSelected={
+ pathname === `/packages/${p.name.replace('@xds/', '')}`
+ }
+ />
+ ))}
+ </XDSSideNavItem>
+ </XDSSideNavSection>
+
+ {/* Components */}
+ <XDSSideNavSection title="Components" isHeaderHidden>
+ <XDSSideNavItem
+ label="Components"
+ collapsible={{defaultIsCollapsed: !isInComponents}}>
+ {componentItems.map(item =>
+ item.type === 'entry' ? (
+ <XDSSideNavItem
+ key={item.name}
+ label={item.name}
+ href={item.href}
+ isSelected={pathname === item.href}
+ />
+ ) : (
+ <XDSSideNavItem
+ key={item.label}
+ label={item.label}
+ collapsible={{
+ defaultIsCollapsed: !item.entries.some(
+ e => pathname === e.href,
+ ),
+ }}>
+ {item.entries.map(entry => (
+ <XDSSideNavItem
+ key={entry.name}
+ label={entry.name}
+ href={entry.href}
+ isSelected={pathname === entry.href}
+ />
+ ))}
+ </XDSSideNavItem>
+ ),
+ )}
+ </XDSSideNavItem>
+ </XDSSideNavSection>
+
+ {/* Utilities */}
+ {utilities.length > 0 && (
+ <XDSSideNavSection title="Utilities" isHeaderHidden>
+ <XDSSideNavItem
+ label="Utilities"
+ collapsible={{defaultIsCollapsed: !isInUtilities}}>
+ {utilities.map(comp => (
+ <XDSSideNavItem
+ key={comp.name}
+ label={comp.name}
+ href={comp.href}
+ isSelected={pathname === comp.href}
+ />
+ ))}
+ </XDSSideNavItem>
+ </XDSSideNavSection>
+ )}
+ </XDSSideNav>
+ }>
+ {children}
+ </XDSAppShell>
+ );
+}
diff --git a/packages/cli/docs/color.doc.mjs b/packages/cli/docs/color.doc.mjs
index 395759fc00..5f5125c630 100644
--- a/packages/cli/docs/color.doc.mjs
+++ b/packages/cli/docs/color.doc.mjs
@@ -3,6 +3,7 @@
export const docs = {
name: 'color',
title: 'Color',
+ category: 'foundations',
description:
'Semantic color tokens for surfaces, text, icons, borders, and status indicators.',
tokenCategory: 'color',
@@ -10,6 +11,7 @@ export const docs = {
sections: [
{
title: 'Overview',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -19,6 +21,7 @@ export const docs = {
},
{
title: 'Surface Colors',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -33,6 +36,7 @@ export const docs = {
},
{
title: 'Usage',
+ category: 'foundations',
content: [
{
type: 'code',
@@ -56,6 +60,7 @@ const styles = stylex.create({
},
{
title: 'Best Practices',
+ category: 'foundations',
content: [
{
type: 'list',
diff --git a/packages/cli/docs/elevation.doc.mjs b/packages/cli/docs/elevation.doc.mjs
index da1ca1c95e..5d2b1e6dcd 100644
--- a/packages/cli/docs/elevation.doc.mjs
+++ b/packages/cli/docs/elevation.doc.mjs
@@ -3,6 +3,7 @@
export const docs = {
name: 'elevation',
title: 'Elevation',
+ category: 'foundations',
description:
'Shadow tokens for visual elevation and inset state rings.',
tokenCategory: 'shadow',
@@ -10,6 +11,7 @@ export const docs = {
sections: [
{
title: 'Overview',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -19,6 +21,7 @@ export const docs = {
},
{
title: 'Elevation Scale',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -33,6 +36,7 @@ export const docs = {
},
{
title: 'Usage',
+ category: 'foundations',
content: [
{
type: 'code',
@@ -56,6 +60,7 @@ const styles = stylex.create({
},
{
title: 'Best Practices',
+ category: 'foundations',
content: [
{
type: 'list',
diff --git a/packages/cli/docs/getting-started.doc.mjs b/packages/cli/docs/getting-started.doc.mjs
index 31298ab8ec..313e21102a 100644
--- a/packages/cli/docs/getting-started.doc.mjs
+++ b/packages/cli/docs/getting-started.doc.mjs
@@ -3,12 +3,14 @@
export const docs = {
name: 'getting-started',
title: 'Getting Started',
+ category: 'guide',
description:
'Go from zero to a working XDS app in five steps.',
sections: [
{
title: 'Install the CLI',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -25,6 +27,7 @@ cd my-app`,
},
{
title: 'Pick a theme',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -44,6 +47,7 @@ export default function RootLayout({children}) {
},
{
title: 'Add your first component',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -68,6 +72,7 @@ export default function Page() {
},
{
title: 'Customize with xstyle',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -89,6 +94,7 @@ const overrides = stylex.create({
},
{
title: 'Run the dev server',
+ category: 'guide',
content: [
{
type: 'prose',
diff --git a/packages/cli/docs/icons.doc.mjs b/packages/cli/docs/icons.doc.mjs
index 19f8fe342f..b302bafeef 100644
--- a/packages/cli/docs/icons.doc.mjs
+++ b/packages/cli/docs/icons.doc.mjs
@@ -6,12 +6,14 @@
export const docs = {
name: 'icons',
title: 'Icons',
+ category: 'foundations',
description:
"Semantic icon names available in XDS. These adapt to the active theme's icon registry.",
sections: [
{
title: 'Available Names',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -53,6 +55,7 @@ export const docs = {
},
{
title: 'Custom Icons',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -72,6 +75,7 @@ import { HeartIcon } from 'lucide-react';
},
{
title: 'Theme Overrides',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -94,6 +98,7 @@ registerIcons({
},
{
title: 'Adding New Icons',
+ category: 'foundations',
content: [
{
type: 'prose',
diff --git a/packages/cli/docs/motion.doc.mjs b/packages/cli/docs/motion.doc.mjs
index f41092dd6c..bdcb7ca8d6 100644
--- a/packages/cli/docs/motion.doc.mjs
+++ b/packages/cli/docs/motion.doc.mjs
@@ -3,6 +3,7 @@
export const docs = {
name: 'motion',
title: 'Motion',
+ category: 'foundations',
description:
'Duration and easing tokens for animations and transitions.',
tokenCategory: 'duration',
@@ -10,6 +11,7 @@ export const docs = {
sections: [
{
title: 'Overview',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -27,6 +29,7 @@ export const docs = {
},
{
title: 'Duration',
+ category: 'foundations',
content: [
{
type: 'token-ref',
@@ -37,6 +40,7 @@ export const docs = {
},
{
title: 'Easing',
+ category: 'foundations',
content: [
{
type: 'token-ref',
@@ -47,6 +51,7 @@ export const docs = {
},
{
title: 'Where Motion Helps',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -60,6 +65,7 @@ export const docs = {
},
{
title: 'Where Motion Hurts',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -73,6 +79,7 @@ export const docs = {
},
{
title: 'Movement Principles',
+ category: 'foundations',
content: [
{
type: 'list',
@@ -88,6 +95,7 @@ export const docs = {
},
{
title: 'Respecting User Preferences',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -97,6 +105,7 @@ export const docs = {
},
{
title: 'Usage',
+ category: 'foundations',
content: [
{
type: 'code',
@@ -121,6 +130,7 @@ const styles = stylex.create({
},
{
title: 'Best Practices',
+ category: 'foundations',
content: [
{
type: 'list',
diff --git a/packages/cli/docs/principles.doc.mjs b/packages/cli/docs/principles.doc.mjs
index 72d7b7f7f3..225fb83b4c 100644
--- a/packages/cli/docs/principles.doc.mjs
+++ b/packages/cli/docs/principles.doc.mjs
@@ -3,12 +3,14 @@
export const docs = {
name: 'principles',
title: 'Principles',
+ category: 'guide',
description:
'Core design principles and rules for building with XDS.',
sections: [
{
title: 'Design Philosophy',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -28,6 +30,7 @@ export const docs = {
},
{
title: 'Rules',
+ category: 'guide',
content: [
{
type: 'list',
@@ -45,6 +48,7 @@ export const docs = {
},
{
title: 'Styling Approach',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -58,6 +62,7 @@ export const docs = {
},
{
title: 'Anti-Patterns',
+ category: 'guide',
content: [
{
type: 'list',
@@ -74,6 +79,7 @@ export const docs = {
},
{
title: 'Design Tokens',
+ category: 'guide',
content: [
{
type: 'prose',
diff --git a/packages/cli/docs/shape.doc.mjs b/packages/cli/docs/shape.doc.mjs
index 7b30b847af..6cf4482a20 100644
--- a/packages/cli/docs/shape.doc.mjs
+++ b/packages/cli/docs/shape.doc.mjs
@@ -3,6 +3,7 @@
export const docs = {
name: 'shape',
title: 'Shape',
+ category: 'foundations',
description:
'Border radius tokens for consistent component rounding — from sharp corners to full pills.',
tokenCategory: 'radius',
@@ -10,6 +11,7 @@ export const docs = {
sections: [
{
title: 'Overview',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -19,6 +21,7 @@ export const docs = {
},
{
title: 'Radius Scale',
+ category: 'foundations',
content: [
{
type: 'token-ref',
@@ -29,6 +32,7 @@ export const docs = {
},
{
title: 'Concentric Radius',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -45,6 +49,7 @@ export const docs = {
},
{
title: 'Best Practices',
+ category: 'foundations',
content: [
{
type: 'list',
diff --git a/packages/cli/docs/spacing.doc.mjs b/packages/cli/docs/spacing.doc.mjs
index 869acde5e4..9545e4ae3f 100644
--- a/packages/cli/docs/spacing.doc.mjs
+++ b/packages/cli/docs/spacing.doc.mjs
@@ -3,6 +3,7 @@
export const docs = {
name: 'spacing',
title: 'Spacing',
+ category: 'foundations',
description:
'Spacing scale tokens for padding, gap, and margin — the rhythmic foundation of XDS layouts.',
tokenCategory: 'spacing',
@@ -10,6 +11,7 @@ export const docs = {
sections: [
{
title: 'Overview',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -19,6 +21,7 @@ export const docs = {
},
{
title: 'Scale',
+ category: 'foundations',
content: [
{
type: 'token-ref',
@@ -29,6 +32,7 @@ export const docs = {
},
{
title: 'Usage',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -55,6 +59,7 @@ const styles = stylex.create({
},
{
title: 'Best Practices',
+ category: 'foundations',
content: [
{
type: 'list',
diff --git a/packages/cli/docs/styling.doc.mjs b/packages/cli/docs/styling.doc.mjs
index 2abaa10f39..d0001c774b 100644
--- a/packages/cli/docs/styling.doc.mjs
+++ b/packages/cli/docs/styling.doc.mjs
@@ -3,12 +3,14 @@
export const docs = {
name: 'styling',
title: 'Styling Components',
+ category: 'guide',
description:
'How to customize component appearance: xstyle prop, Tailwind, StyleX, className, rest props, compound component patterns, and theming hooks.',
sections: [
{
title: 'Overview',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -32,6 +34,7 @@ export const docs = {
},
{
title: 'xstyle Prop',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -82,6 +85,7 @@ const overrides = stylex.create({
},
{
title: 'Tailwind Integration',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -111,6 +115,7 @@ const overrides = stylex.create({
},
{
title: 'className and style Props',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -133,6 +138,7 @@ const overrides = stylex.create({
},
{
title: 'Rest Props (Prop Drilling)',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -166,6 +172,7 @@ const overrides = stylex.create({
},
{
title: 'Compound Components',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -211,6 +218,7 @@ const overrides = stylex.create({
},
{
title: 'Theming via xds-* Class Names',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -245,6 +253,7 @@ const overrides = stylex.create({
},
{
title: 'Design Tokens',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -292,6 +301,7 @@ const styles = stylex.create({
},
{
title: 'What NOT to Do',
+ category: 'guide',
content: [
{
type: 'list',
diff --git a/packages/cli/docs/theme.doc.mjs b/packages/cli/docs/theme.doc.mjs
index 88761e50e7..76e9ba76aa 100644
--- a/packages/cli/docs/theme.doc.mjs
+++ b/packages/cli/docs/theme.doc.mjs
@@ -3,12 +3,14 @@
export const docs = {
name: 'theme',
title: 'Theme System',
+ category: 'guide',
description:
'XDSTheme provider, custom themes, theme build for production/SSR, light/dark mode, and component style overrides.',
sections: [
{
title: 'Quick Start',
+ category: 'guide',
content: [
{
type: 'code',
@@ -49,6 +51,7 @@ function App() {
},
{
title: 'Available Themes',
+ category: 'guide',
content: [
{
type: 'table',
@@ -79,6 +82,7 @@ function App() {
},
{
title: 'XDSTheme Props',
+ category: 'guide',
content: [
{
type: 'table',
@@ -98,6 +102,7 @@ function App() {
},
{
title: 'Creating a Custom Theme',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -113,6 +118,7 @@ function App() {
},
{
title: 'defineTheme',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -177,6 +183,7 @@ const myTheme = defineTheme({
},
{
title: 'Extending a Theme',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -214,6 +221,7 @@ const brandTheme = defineTheme({
},
{
title: 'Component Style Overrides',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -264,6 +272,7 @@ const brandTheme = defineTheme({
},
{
title: 'Custom Variants',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -312,6 +321,7 @@ const brandTheme = defineTheme({
},
{
title: 'Building Themes for Production',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -368,6 +378,7 @@ import './themes/ocean.css';
},
{
title: 'Runtime vs Built Themes',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -430,6 +441,7 @@ import './themes/ocean.css';
},
{
title: 'Light/Dark Mode',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -458,6 +470,7 @@ import './themes/ocean.css';
},
{
title: 'Nesting Themes',
+ category: 'guide',
content: [
{
type: 'prose',
@@ -483,6 +496,7 @@ import './themes/ocean.css';
},
{
title: 'useXDSTheme Hook',
+ category: 'guide',
content: [
{
type: 'code',
diff --git a/packages/cli/docs/tokens.doc.mjs b/packages/cli/docs/tokens.doc.mjs
index a928815397..b71a4c4b14 100644
--- a/packages/cli/docs/tokens.doc.mjs
+++ b/packages/cli/docs/tokens.doc.mjs
@@ -7,7 +7,8 @@
export const docs = {
"name": "tokens",
- "title": "XDS Design Tokens",
+ "title": "All Tokens",
+ "category": "foundations",
"description": "Complete reference for spacing, color, radius, typography, shadow, motion, and size tokens.",
"sections": [
{
diff --git a/packages/cli/docs/typography.doc.mjs b/packages/cli/docs/typography.doc.mjs
index 053ea66ab6..cecc3af040 100644
--- a/packages/cli/docs/typography.doc.mjs
+++ b/packages/cli/docs/typography.doc.mjs
@@ -3,6 +3,7 @@
export const docs = {
name: 'typography',
title: 'Typography',
+ category: 'foundations',
description:
'Font families, geometric type scale, weight, line-height, and semantic text tokens for consistent, accessible text styling.',
tokenCategory: 'typography',
@@ -11,6 +12,7 @@ export const docs = {
// ── Overview ────────────────────────────────────────────────────────────
{
title: 'Overview',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -26,6 +28,7 @@ export const docs = {
// ── Font Families ───────────────────────────────────────────────────────
{
title: 'Font Families',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -42,6 +45,7 @@ export const docs = {
// ── Font Sizes ──────────────────────────────────────────────────────────
{
title: 'Font Sizes',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -58,6 +62,7 @@ export const docs = {
// ── Font Weights ────────────────────────────────────────────────────────
{
title: 'Font Weights',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -74,6 +79,7 @@ export const docs = {
// ── Line Height ─────────────────────────────────────────────────────────
{
title: 'Line Height',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -89,6 +95,7 @@ export const docs = {
// ── Type Scale ──────────────────────────────────────────────────────────
{
title: 'Type Scale',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -105,6 +112,7 @@ export const docs = {
// ── Display Text ────────────────────────────────────────────────────────
{
title: 'Display Text',
+ category: 'foundations',
content: [
{
type: 'prose',
@@ -120,6 +128,7 @@ export const docs = {
// ── Usage ────────────────────────────────────────────────────────────────
{
title: 'Usage',
+ category: 'foundations',
content: [
{
type: 'code',
@@ -183,6 +192,7 @@ const denseTheme = defineTheme({
// ── Best Practices ──────────────────────────────────────────────────────
{
title: 'Best Practices',
+ category: 'foundations',
content: [
{
type: 'list',
diff --git a/packages/core/src/Layer/Layer.doc.mjs b/packages/core/src/Layer/Layer.doc.mjs
index 3fe7d4f2fd..33996adaec 100644
--- a/packages/core/src/Layer/Layer.doc.mjs
+++ b/packages/core/src/Layer/Layer.doc.mjs
@@ -1,84 +1,32 @@
/** @type {import('../docs-types').ComponentDoc} */
export const docs = {
- name: 'Layer',
+ name: 'useXDSLayer',
group: 'Utilities',
keywords: ["layer","overlay","popover","positioning","anchor","floating","dropdown","popper","popup","portal"],
- components: [
+ props: [
{
- name: 'useXDSLayer',
+ name: 'mode',
+ type: "'context' | 'fixed'",
description:
- 'Core layer hook with type-safe modes for different positioning strategies (context mode for anchor positioning, fixed mode for manual coordinates).',
- props: [
- {
- name: 'mode',
- type: "'context' | 'fixed'",
- description:
- 'Positioning strategy: context uses CSS anchor positioning relative to a trigger ref; fixed uses explicit x/y coordinates.',
- required: true,
- },
- {
- name: 'onShow',
- type: '() => void',
- description: 'Callback fired when the layer becomes visible.',
- },
- {
- name: 'onHide',
- type: '() => void',
- description: 'Callback fired when the layer is hidden.',
- },
- {
- name: 'xstyle',
- type: 'StyleXStyles',
- description:
- 'StyleX styles for layout customization.',
- },
- ], },
- ],
- usage: {
- description:
- 'Layer is a core positioning hook for rendering overlay content using CSS Anchor Positioning and the Popover API. Use it as the foundation for building popovers, hover cards, and tooltips without React portals.',
- bestPractices: [
- { guidance: true, description: 'Use context mode for anchor-positioned overlays relative to a trigger element, and fixed mode for manually positioned overlays at specific coordinates.' },
- { guidance: true, description: 'Build on higher-level components like Popover, HoverCard, and Tooltip instead of using Layer directly for common overlay patterns.' },
- { guidance: false, description: 'Implement ARIA patterns directly in a Layer — leave accessibility semantics to the higher-level components that build on it.' },
- ],
- },
-};
-
-/** @type {import('../docs-types').ComponentDoc} */
-export const docsZh = {
- name: 'Layer',
- components: [
+ 'Positioning strategy: context uses CSS anchor positioning relative to a trigger ref; fixed uses explicit x/y coordinates.',
+ required: true,
+ },
+ {
+ name: 'onShow',
+ type: '() => void',
+ description: 'Callback fired when the layer becomes visible.',
+ },
{
- name: 'useXDSLayer',
+ name: 'onHide',
+ type: '() => void',
+ description: 'Callback fired when the layer is hidden.',
+ },
+ {
+ name: 'xstyle',
+ type: 'StyleXStyles',
description:
- '核心层 Hook,提供类型安全的模式以支持不同定位策略(上下文模式用于锚点定位,固定模式用于手动坐标)。',
- props: [
- {
- name: 'mode',
- type: "'context' | 'fixed'",
- description:
- '定位策略:context 使用 CSS 锚点定位相对于触发 ref 定位;fixed 使用显式 x/y 坐标。',
- required: true,
- },
- {
- name: 'onShow',
- type: '() => void',
- description: '当层变为可见时触发的回调。',
- },
- {
- name: 'onHide',
- type: '() => void',
- description: '当层被隐藏时触发的回调。',
- },
- {
- name: 'xstyle',
- type: 'StyleXStyles',
- description:
- '用于布局自定义的 StyleX 样式。',
- },
- ],
+ 'StyleX styles for layout customization.',
},
],
usage: {
@@ -91,30 +39,3 @@ export const docsZh = {
],
},
};
-
-/** @type {import('../docs-types').TranslationDoc} */
-export const docsDense = {
- description:
- 'Core hook for overlay positioning using CSS Anchor Positioning + Popover API; no React portals needed. Popover, HoverCard, Tooltip build on this.',
- usage: {
- description:
- 'Layer is a core positioning hook for rendering overlay content using CSS Anchor Positioning and the Popover API. Use it as the foundation for building popovers, hover cards, and tooltips without React portals.',
- bestPractices: [
- { guidance: true, description: 'Use context mode for anchor-positioned overlays relative to a trigger element, and fixed mode for manually positioned overlays at specific coordinates.' },
- { guidance: true, description: 'Build on higher-level components like Popover, HoverCard, and Tooltip instead of using Layer directly for common overlay patterns.' },
- { guidance: false, description: 'Implement ARIA patterns directly in a Layer — leave accessibility semantics to the higher-level components that build on it.' },
- ],
- },
- components: [
- {
- name: 'useXDSLayer',
- description: 'Core layer hook w/ type-safe modes for positioning (context=anchor, fixed=coordinates).',
- propDescriptions: {
- mode: 'Positioning strategy: context uses CSS anchor positioning relative to trigger ref; fixed uses explicit x/y coordinates.',
- onShow: 'Callback when layer becomes visible.',
- onHide: 'Callback when layer hidden.',
- xstyle: 'StyleX styles for layout customization.',
- },
- },
- ],
-};
diff --git a/packages/core/src/Resizable/Resizable.doc.mjs b/packages/core/src/Resizable/Resizable.doc.mjs
index 44c9bbf7da..7743b12941 100644
--- a/packages/core/src/Resizable/Resizable.doc.mjs
+++ b/packages/core/src/Resizable/Resizable.doc.mjs
@@ -1,6 +1,7 @@
/** @type {import('../docs-types').ComponentDoc} */
export const docs = {
name: 'Resizable',
+ group: 'Resizable',
keywords: [
'resize',
'resizable',
diff --git a/packages/core/src/Resizable/useXDSResizable.doc.mjs b/packages/core/src/Resizable/useXDSResizable.doc.mjs
index 3ec4b5f09a..8efd6e088b 100644
--- a/packages/core/src/Resizable/useXDSResizable.doc.mjs
+++ b/packages/core/src/Resizable/useXDSResizable.doc.mjs
@@ -1,6 +1,7 @@
/** @type {import('../docs-types').HookDoc} */
export const docs = {
name: 'useXDSResizable',
+ group: 'Resizable',
keywords: ['resize', 'resizable', 'drag', 'split', 'panel', 'sidebar', 'divider', 'splitter'],
params: [
{
diff --git a/packages/core/src/Stack/Stack.doc.mjs b/packages/core/src/Stack/Stack.doc.mjs
index db57e26192..411e98963d 100644
--- a/packages/core/src/Stack/Stack.doc.mjs
+++ b/packages/core/src/Stack/Stack.doc.mjs
@@ -169,56 +169,6 @@ export const docs = {
},
],
},
- {
- name: 'stack',
- description:
- 'Low-level StyleX utility for creating flex containers with stack behavior. Use when the component API is insufficient.',
- props: [
- {
- name: 'direction',
- type: "'horizontal' | 'vertical'",
- description: 'Stack direction.',
- required: true,
- },
- {
- name: 'gap',
- type: 'SpacingStep',
- description:
- 'Numeric spacing step controlling the gap between items: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10.',
- },
- {
- name: 'crossAlign',
- type: "'start' | 'center' | 'end' | 'stretch'",
- description: 'Cross-axis alignment of all items.',
- },
- {
- name: 'wrap',
- type: "'nowrap' | 'wrap' | 'wrap-reverse'",
- description: 'Flex wrap behavior.',
- default: "'nowrap'",
- },
- ],
- },
- {
- name: 'stackItem',
- description:
- 'Low-level StyleX utility for controlling flex item behavior. Use when the component API is insufficient.',
- props: [
- {
- name: 'size',
- type: "'static' | 'fill'",
- description:
- 'Flex grow behavior: static keeps natural size, fill expands to consume remaining space.',
- default: "'static'",
- },
- {
- name: 'crossAlignSelf',
- type: "'start' | 'center' | 'end' | 'stretch'",
- description:
- 'Override the cross-axis alignment for this individual item.',
- },
- ],
- },
],
usage: {
description:
@@ -401,56 +351,6 @@ export const docsZh = {
},
],
},
- {
- name: 'stack',
- description:
- '底层 StyleX 工具函数,用于创建具有堆叠行为的 flex 容器。在组件 API 无法满足需求时使用。',
- props: [
- {
- name: 'direction',
- type: "'horizontal' | 'vertical'",
- description: '堆叠方向。',
- required: true,
- },
- {
- name: 'gap',
- type: 'SpacingStep',
- description:
- '控制元素间距的数值间距步进:0、0.5、1、1.5、2、3、4、5、6、8、10。',
- },
- {
- name: 'crossAlign',
- type: "'start' | 'center' | 'end' | 'stretch'",
- description: '所有元素的交叉轴对齐方式。',
- },
- {
- name: 'wrap',
- type: "'nowrap' | 'wrap' | 'wrap-reverse'",
- description: 'Flex 换行行为。',
- default: "'nowrap'",
- },
- ],
- },
- {
- name: 'stackItem',
- description:
- '底层 StyleX 工具函数,用于控制 flex 子元素的行为。在组件 API 无法满足需求时使用。',
- props: [
- {
- name: 'size',
- type: "'static' | 'fill'",
- description:
- 'Flex 增长行为:static 保持自然尺寸,fill 扩展以占据剩余空间。',
- default: "'static'",
- },
- {
- name: 'crossAlignSelf',
- type: "'start' | 'center' | 'end' | 'stretch'",
- description:
- '覆盖此元素的交叉轴对齐方式。',
- },
- ],
- },
],
usage: {
description:
@@ -519,23 +419,5 @@ export const docsDense = {
children: 'Item content.',
},
},
- {
- name: 'stack',
- description: 'Low-level StyleX utility for flex containers w/ stack behavior.',
- propDescriptions: {
- direction: 'Stack direction.',
- gap: 'Numeric spacing step for gap: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10.',
- crossAlign: 'Cross-axis alignment of all items.',
- wrap: 'Flex wrap behavior.',
- },
- },
- {
- name: 'stackItem',
- description: 'Low-level StyleX utility for flex item behavior.',
- propDescriptions: {
- size: 'Flex grow: static=natural size, fill=expand to remaining space.',
- crossAlignSelf: 'Override cross-axis alignment for this item.',
- },
- },
],
};
\ No newline at end of file
diff --git a/packages/core/src/docs-types.ts b/packages/core/src/docs-types.ts
index f8055c94b6..c86c21b421 100644
--- a/packages/core/src/docs-types.ts
+++ b/packages/core/src/docs-types.ts
@@ -284,33 +284,7 @@ interface BaseDoc {
* Components without a group appear flat in alphabetical order.
* Groups cluster related components that are always used together
* or are variants of each other. */
- group?:
- | 'Avatar'
- | 'Breadcrumbs'
- | 'Button'
- | 'Card'
- | 'Chat'
- | 'Checkbox'
- | 'Collapsible'
- | 'CommandPalette'
- | 'Dialog'
- | 'DropdownMenu'
- | 'Field'
- | 'Layout'
- | 'List'
- | 'MetadataList'
- | 'MobileNav'
- | 'Radio'
- | 'SegmentedControl'
- | 'Selector'
- | 'SideNav'
- | 'Table'
- | 'Tabs'
- | 'Toast'
- | 'TopNav'
- | 'TreeList'
- | 'Typeahead'
- | 'Utilities';
+ group?: string;
/** Theming configuration. Documents the stable CSS class names
* rendered by this component that themes can target via `@scope`
* selectors in `defineTheme`. */
@@ -502,10 +476,12 @@ export interface ReferenceSection {
export interface ReferenceDoc {
/** URL-safe identifier, used as the CLI topic name. e.g. 'tokens', 'principles' */
name: string;
- /** Human-readable title. e.g. 'XDS Design Tokens' */
+ /** Human-readable title. e.g. 'All Tokens' */
title: string;
/** One-line summary shown in topic listings. */
description: string;
+ /** Navigation category: 'guide' or 'foundations'. */
+ category?: string;
/** Ordered sections that make up the doc. */
sections: ReferenceSection[];
/** Token category for foundational docs that map to a token section.
@@ -671,6 +647,8 @@ export interface HookReturnDoc {
export interface HookDoc {
/** Hook name exactly as exported, e.g. 'useMediaQuery', 'useFocusTrap'. */
name: string;
+ /** Optional group for sidebar/docs organization — same as ComponentDoc.group. */
+ group?: string;
/** Search keywords for CLI discovery. */
keywords?: string[];
/** Hook parameters or options object fields. */
@@ -689,14 +667,7 @@ export interface HookDoc {
/** Import path, e.g. '@xds/core/hooks' or '@xds/core/Toast'. */
importPath?: string;
/** Category for grouping in listings. */
- category?:
- | 'focus'
- | 'layout'
- | 'animation'
- | 'interaction'
- | 'data'
- | 'media'
- | 'streaming';
+ category?: string;
}
/**
diff --git a/scripts/generate-token-docs.mjs b/scripts/generate-token-docs.mjs
index 5752a4e715..c286de93ce 100644
--- a/scripts/generate-token-docs.mjs
+++ b/scripts/generate-token-docs.mjs
@@ -258,7 +258,8 @@ const output = `\
export const docs = ${JSON.stringify(
{
name: 'tokens',
- title: 'XDS Design Tokens',
+ title: 'All Tokens',
+ category: 'foundations',
description:
'Complete reference for spacing, color, radius, typography, shadow, motion, and size tokens.',
sections,