Skip to content

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

TypeScript

feat(templates): add Shell — Side Nav page template (#3246)

Ernest609e35800a94
diff --git a/apps/docsite/src/components/templateComponents.ts b/apps/docsite/src/components/templateComponents.ts
index 3c3af96448..7eb20511de 100644
--- a/apps/docsite/src/components/templateComponents.ts
+++ b/apps/docsite/src/components/templateComponents.ts
@@ -117,6 +117,10 @@ export const TEMPLATE_COMPONENTS: Record<
'side-gallery': lazy(
() => import('../../../../packages/cli/templates/pages/side-gallery/page'),
),
+ 'shell-side-nav': lazy(
+ () =>
+ import('../../../../packages/cli/templates/pages/shell-side-nav/page'),
+ ),
'shell-top-nav': lazy(
() => import('../../../../packages/cli/templates/pages/shell-top-nav/page'),
),
diff --git a/packages/cli/templates/pages/shell-side-nav/page.tsx b/packages/cli/templates/pages/shell-side-nav/page.tsx
new file mode 100644
index 0000000000..cc7574a096
--- /dev/null
+++ b/packages/cli/templates/pages/shell-side-nav/page.tsx
@@ -0,0 +1,242 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+'use client';
+
+import {useState} from 'react';
+import {AppShell} from '@astryxdesign/core/AppShell';
+import {Divider} from '@astryxdesign/core/Divider';
+import {Layout, LayoutContent, LayoutFooter} from '@astryxdesign/core/Layout';
+import {
+ SideNav,
+ SideNavHeading,
+ SideNavItem,
+ SideNavSection,
+} from '@astryxdesign/core/SideNav';
+import {NavIcon} from '@astryxdesign/core/NavIcon';
+import {Icon} from '@astryxdesign/core/Icon';
+import type {IconType} from '@astryxdesign/core/Icon';
+import {MoreMenu} from '@astryxdesign/core/MoreMenu';
+import {StatusDot} from '@astryxdesign/core/StatusDot';
+import type {StatusDotVariant} from '@astryxdesign/core/StatusDot';
+import {Card} from '@astryxdesign/core/Card';
+import {Stack, VStack, HStack} from '@astryxdesign/core/Stack';
+import {
+ SparklesIcon,
+ PlusIcon,
+ MagnifyingGlassIcon,
+ BookOpenIcon,
+ Cog6ToothIcon,
+ UserCircleIcon,
+ UserIcon,
+ BuildingOffice2Icon,
+ CodeBracketIcon,
+} from '@heroicons/react/24/outline';
+
+type Conversation = {
+ label: string;
+ status: StatusDotVariant;
+ statusLabel: string;
+};
+
+type Workspace = {
+ name: string;
+ icon: IconType;
+ chats: Conversation[];
+};
+
+const WORKSPACES: Workspace[] = [
+ {
+ name: 'Personal',
+ icon: UserIcon,
+ chats: [
+ {
+ label: 'Weekend trip planning',
+ status: 'success',
+ statusLabel: 'Active',
+ },
+ {
+ label: 'Recipe ideas for the week',
+ status: 'neutral',
+ statusLabel: 'Idle',
+ },
+ {
+ label: 'Book recommendations',
+ status: 'warning',
+ statusLabel: 'Needs review',
+ },
+ {label: 'Home workout plan', status: 'neutral', statusLabel: 'Idle'},
+ ],
+ },
+ {
+ name: 'Acme Corp',
+ icon: BuildingOffice2Icon,
+ chats: [
+ {label: 'Q3 roadmap draft', status: 'accent', statusLabel: 'In progress'},
+ {
+ label: 'Customer onboarding flow',
+ status: 'success',
+ statusLabel: 'Active',
+ },
+ {
+ label: 'Pricing strategy review',
+ status: 'warning',
+ statusLabel: 'Needs review',
+ },
+ {label: 'Standup summary', status: 'neutral', statusLabel: 'Idle'},
+ ],
+ },
+ {
+ name: 'Open Source',
+ icon: CodeBracketIcon,
+ chats: [
+ {
+ label: 'StyleX migration notes',
+ status: 'accent',
+ statusLabel: 'In progress',
+ },
+ {
+ label: 'Skeleton loading states',
+ status: 'success',
+ statusLabel: 'Active',
+ },
+ {label: 'Accessibility audit', status: 'error', statusLabel: 'Blocked'},
+ {label: 'Release notes v4.0', status: 'neutral', statusLabel: 'Idle'},
+ ],
+ },
+];
+
+const SELECTED_CHAT = 'StyleX migration notes';
+
+const MESSAGES = [
+ {role: 'assistant', width: '78%', height: 104},
+ {role: 'user', width: '48%', height: 48},
+ {role: 'assistant', width: '64%', height: 132},
+ {role: 'user', width: '38%', height: 40},
+];
+
+function ConversationItem({
+ label,
+ status,
+ statusLabel,
+ isSelected,
+}: {
+ label: string;
+ status: StatusDotVariant;
+ statusLabel: string;
+ isSelected?: boolean;
+}) {
+ const [isHovered, setIsHovered] = useState(false);
+ const [isMenuOpen, setIsMenuOpen] = useState(false);
+ const showMenu = isHovered || isMenuOpen;
+
+ return (
+ <Stack
+ onMouseEnter={() => setIsHovered(true)}
+ onMouseLeave={() => setIsHovered(false)}>
+ <SideNavItem
+ label={label}
+ href="#"
+ isSelected={isSelected}
+ endContent={
+ showMenu ? (
+ <MoreMenu
+ size="sm"
+ label="Conversation options"
+ hasAutoFocus={false}
+ onOpenChange={setIsMenuOpen}
+ items={[
+ {label: 'Pin', onClick: () => {}},
+ {label: 'Rename', onClick: () => {}},
+ {label: 'Archive', onClick: () => {}},
+ {label: 'Delete', onClick: () => {}},
+ ]}
+ />
+ ) : (
+ <StatusDot variant={status} label={statusLabel} />
+ )
+ }
+ />
+ </Stack>
+ );
+}
+
+export default function ShellSideNav() {
+ return (
+ <AppShell
+ contentPadding={0}
+ sideNav={
+ <SideNav
+ collapsible
+ resizable={{defaultWidth: 300, minWidth: 220, maxWidth: 420}}
+ header={
+ <SideNavHeading
+ heading="AI Assistant"
+ icon={<NavIcon icon={<Icon icon={SparklesIcon} size="sm" />} />}
+ headingHref="#"
+ />
+ }
+ footer={
+ <SideNavSection title="Account" isHeaderHidden>
+ <SideNavItem label="Settings" icon={Cog6ToothIcon} href="#" />
+ <SideNavItem label="Sarah Chen" icon={UserCircleIcon} href="#" />
+ </SideNavSection>
+ }>
+ <SideNavSection title="Menu" isHeaderHidden>
+ <SideNavItem label="New chat" icon={PlusIcon} href="#" />
+ <SideNavItem label="Search" icon={MagnifyingGlassIcon} href="#" />
+ <SideNavItem label="Library" icon={BookOpenIcon} href="#" />
+ </SideNavSection>
+ <Divider />
+ <SideNavSection title="Workspaces" isHeaderHidden>
+ {WORKSPACES.map(workspace => (
+ <SideNavItem
+ key={workspace.name}
+ label={workspace.name}
+ icon={workspace.icon}
+ collapsible={{defaultIsCollapsed: false}}>
+ <VStack gap={0.5}>
+ {workspace.chats.map(chat => (
+ <ConversationItem
+ key={chat.label}
+ label={chat.label}
+ status={chat.status}
+ statusLabel={chat.statusLabel}
+ isSelected={chat.label === SELECTED_CHAT}
+ />
+ ))}
+ </VStack>
+ </SideNavItem>
+ ))}
+ </SideNavSection>
+ </SideNav>
+ }>
+ <Layout
+ height="fill"
+ contentWidth={768}
+ content={
+ <LayoutContent padding={6}>
+ <VStack gap={5}>
+ {MESSAGES.map((message, mi) => (
+ <HStack
+ key={mi}
+ hAlign={message.role === 'assistant' ? 'start' : 'end'}>
+ <Card
+ variant="muted"
+ padding={0}
+ width={message.width}
+ height={message.height}
+ />
+ </HStack>
+ ))}
+ </VStack>
+ </LayoutContent>
+ }
+ footer={
+ <LayoutFooter>
+ <Card variant="muted" padding={0} width="100%" height={56} />
+ </LayoutFooter>
+ }
+ />
+ </AppShell>
+ );
+}
diff --git a/packages/cli/templates/pages/shell-side-nav/template.doc.mjs b/packages/cli/templates/pages/shell-side-nav/template.doc.mjs
new file mode 100644
index 0000000000..0b2c935252
--- /dev/null
+++ b/packages/cli/templates/pages/shell-side-nav/template.doc.mjs
@@ -0,0 +1,12 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/** @type {import('../../../../core/src/docs-types').TemplateDoc} */
+export const doc = {
+ type: 'page',
+ name: 'Side Nav',
+ displayName: 'Side Nav',
+ description:
+ 'A side-nav app shell with a collapsible, resizable SideNav — new chat, search, library, and workspace-grouped conversations with status dots — over static grey-card conversation and composer placeholders.',
+ isReady: true,
+ category: 'Shell - Left Sidebar',
+};