Skip to content

XDSPageNav (sidebar navigation) #84

Closed

Description

@cixzhang

Spec (revised 2026-02-21)

Sidebar navigation component for application pages. Supports collapsible sections, nested items, selected state, icons, and responsive collapse.

Internal usage

  • XDSPageNav: 26 usages (container — low because apps have one)
  • XDSPageNavItem: 12,885 usages
  • XDSPageNavSection: 2,327 usages
  • XDSPageNavCollapsibleItem: 1,054 usages
  • internal component: 4,921 usages (composes PageNav with built-in common data across tools)

External comparison

System Component Approach
Mantine AppShell.Navbar + NavLink NavLink has label, icon, active, children (nesting), opened
Ant Design Menu (mode="inline") Data-driven items array, selectedKeys, openKeys
MUI Drawer + List/ListItemButton Composition with List components, manual nesting
shadcn/ui Sidebar (new) SidebarMenu, SidebarMenuItem, SidebarMenuButton

Mantine's NavLink is closest to internal XDSPageNavItem — single component with icon, label, active state, nesting.

Key decisions

Decision Choice Rationale
Composition over config Children-based Matches XDS convention, flexible
collapsible prop Uses useXDSCollapsible (#187) Consistent primitive pattern
isSelected not isActive More specific Matches internal API
isSelected management Manual in core, router helpers in framework packages Framework-agnostic core
Router integration useXDSNavItemProps hook in @xds/next (packages/integrations/next/) Spread helper pattern: {...useXDSNavItemProps({ href, match })}. Supports exact, prefix, and custom matching.
CommonPageNav equivalent None — app-level concern Internal CommonPageNav bakes in Meta-specific common nav items
Separate from AppShell PageNav = content, AppShell = layout Clean separation. AppShell owns positioning, sticky, scroll.
No isFixedPosition AppShell controls positioning PageNav doesn't own layout
Collapsed nav (icon-only) Deferred to v2 Complex — needs icon-only nav items. AppShell owns sidebar visibility.
Naming convention Flat (XDSPageNavItem) not compound (XDSPageNav.Item) Consistent with XDS conventions

Visual structure

Five zones stacked vertically:

┌─────────────────────┐
│ Header (sticky)     │ ← slot: header (product icon/name, suite/account context)
├─────────────────────┤
│ Action area (sticky)│ ← slot: stickyContent (create button, pinned items)
├─────────────────────┤
│                     │
│ Nav sections        │ ← children (scrollable)
│                     │
├─────────────────────┤
│ Footer              │ ← slot: footer (promo cards, etc.)
├─────────────────────┤
│ Footer icons        │ ← slot: footerIcons (icon buttons / menus)
└─────────────────────┘

Proposed API

interface XDSPageNavProps {
  /** Header area — typically XDSPageNavHeader. Sticky at top. */
  header?: ReactNode;
  /** Content pinned below header (e.g., create button, top-level items). Sticky. */
  stickyContent?: ReactNode;
  /** Navigation sections and items. Scrollable. */
  children: ReactNode;
  /** Footer area above icon bar (e.g., promo cards) */
  footer?: ReactNode;
  /** Footer icon bar (e.g., back, help, notifications, avatar) */
  footerIcons?: ReactNode;
  /** StyleX overrides */
  xstyle?: StyleXStyles;
  "data-testid"?: string;
}

interface XDSPageNavHeaderProps {
  /** Product/app icon */
  icon?: ReactNode;
  /** Product/app name */
  title: string;
  /** Link for the title (e.g., product home) */
  titleHref?: string;
  /** Text above the title (e.g., suite name) */
  supertitle?: string;
  /** Link for the supertitle (e.g., suite home) */
  supertitleHref?: string;
  /** Text below the title (e.g., account context) */
  subtitle?: string;
  /** Link for the subtitle */
  subtitleHref?: string;
  /** Show dropdown chevron indicator */
  hasChevron?: boolean;
  /**
   * Menu content shown in a popover. When provided, the header composes
   * XDSPopover internally (lazy loaded). The trigger boundary is determined
   * automatically:
   * - No hrefs → whole header is the trigger
   * - With hrefs → links are independent, chevron/remaining area is the trigger
   * Popover minWidth defaults to the header's width (matching sidebar context).
   * Menu content can set its own width to go wider (e.g., mega menus).
   */
  menu?: ReactNode;
  /** StyleX overrides */
  xstyle?: StyleXStyles;
  "data-testid"?: string;
}

interface XDSPageNavItemProps {
  /** Item label */
  label: string;
  /** Icon (outline) */
  icon?: XDSIconType;
  /** Icon when selected (filled) */
  selectedIcon?: XDSIconType;
  /** Current page indicator */
  isSelected?: boolean;
  isDisabled?: boolean;
  /** Navigation URL */
  href?: string;
  onClick?: (e: React.MouseEvent) => void;
  /** Right-side content (badges, counts) */
  endContent?: ReactNode;
  /** Sub-items for nesting */
  children?: ReactNode;
  /** Collapsible config from useXDSCollapsible (#187) */
  collapsible?: XDSCollapsibleConfig;
  "data-testid"?: string;
}

interface XDSPageNavSectionProps {
  title: string;
  subtitle?: string;
  children: ReactNode;
  collapsible?: XDSCollapsibleConfig;
  endContent?: ReactNode;
  isHeaderHidden?: boolean;
  "data-testid"?: string;
}

Usage

// Single product — title links home
<XDSPageNav
  header={<XDSPageNavHeader icon={<AppIcon />} title="My App" titleHref="/" />}
  stickyContent={<XDSButton label="Create new" variant="primary" />}
  footerIcons={<>
    <XDSButton icon={HelpIcon} />
    <XDSButton icon={BellIcon} />
  </>}
>
  <XDSPageNavSection title="Main">
    <XDSPageNavItem
      label="Dashboard"
      icon={HomeIcon}
      selectedIcon={HomeIconSolid}
      isSelected={page === "dashboard"}
      href="/dashboard"
    />
    <XDSPageNavItem
      label="Projects"
      icon={FolderIcon}
      href="/projects"
      endContent={<XDSBadge label="3" />}
    />
  </XDSPageNavSection>

  <XDSPageNavSection title="Settings" collapsible={useXDSCollapsible()}>
    <XDSPageNavItem label="General" href="/settings/general" />
    <XDSPageNavItem label="Security" href="/settings/security" />
  </XDSPageNavSection>
</XDSPageNav>

// Suite — supertitle + title with independent links, menu on chevron
<XDSPageNav
  header={
    <XDSPageNavHeader
      icon={<SuiteIcon />}
      supertitle="Suite Name"
      supertitleHref="/suite"
      title="Product Name"
      titleHref="/product"
      menu={<ProductSwitcher />}
    />
  }
>
  {/* ... */}
</XDSPageNav>

// Account context — subtitle below title, whole header triggers menu
<XDSPageNav
  header={
    <XDSPageNavHeader
      icon={<AppIcon />}
      title="Product Name"
      subtitle="Business Account"
      menu={<AccountSwitcher />}
    />
  }
>
  {/* ... */}
</XDSPageNav>

// With AppShell
<XDSAppShell
  topNav={<XDSTopNav title="My App" />}
  pageNav={
    <XDSPageNav header={<XDSPageNavHeader ... />}>
      {/* ... */}
    </XDSPageNav>
  }
>
  {content}
</XDSAppShell>

Header interaction model

XDSPageNavHeader composes XDSPopover internally (lazy loaded) when menu is provided. The trigger boundary is determined automatically based on which hrefs are present:

Props provided Behavior
titleHref only, no menu Whole header is one link
titleHref + supertitleHref, no menu Each text is an independent link
menu only, no hrefs Whole header is the popover trigger
menu + hrefs Links are independent <a> elements, chevron/remaining area is the popover trigger

Popover sizing: minWidth defaults to the header's measured width (matching the sidebar context). Menu content can set its own width to go wider — mega menus typically extend beyond the sidebar into the content area.

hasChevron: Automatically shown when menu is provided. Can be set explicitly for cases where the trigger is managed externally.

Icon: Follows the title link when titleHref is provided. Static otherwise.

Router integration (separate package)

Framework-agnostic core with router helpers in packages/integrations/next/:

// @xds/next — useXDSNavItemProps hook
import { useXDSNavItemProps } from "@xds/next";

// Exact match (default)
<XDSPageNavItem label="Dashboard" {...useXDSNavItemProps({ href: "/dashboard" })} />

// Prefix match — stays selected on /settings/*
<XDSPageNavItem label="Settings" {...useXDSNavItemProps({ href: "/settings", match: "prefix" })} />

// Custom matcher
<XDSPageNavItem label="Admin" {...useXDSNavItemProps({ href: "/admin", match: (path) => path.startsWith("/admin") })} />

Returns { href, isSelected, onClick } — reads current route, sets isSelected based on path matching, wires up client-side navigation.

Selected state visual treatment

  • Light accent background fill, full-width rounded pill shape
  • Icon + label
  • aria-current="page" for accessibility

Accessibility

  • <nav aria-label="Page navigation">
  • aria-current="page" on selected item
  • Sections: role="group" with aria-labelledby
  • Collapsible: aria-expanded on trigger
  • Keyboard: Tab through items, Enter/Space to activate

v1 scope

Include:

  • XDSPageNav container with header, stickyContent, footer, footerIcons slots + children
  • XDSPageNavHeader — composition for header area (single product, suite, account context variants)
  • XDSPageNavItem — icon, selectedIcon, label, isSelected, href, onClick, endContent, nesting, collapsible
  • XDSPageNavSection — title, collapsible, children

Defer:

  • Nested nav variant (back button + breadcrumb pattern)
  • Footer icons (need menus, icon-only button pattern settled)
  • Promo card pattern
  • @xds/next router integration package
  • Collapsed nav / icon-only sidebar
  • Expand-on-hover
  • Animation
  • Mobile responsive (AppShell handles)

Depends on

Activity

  1. added this to the Component set 2 milestone on Feb 6, 2026
  2. added
    enhancement
    on Feb 18, 2026
  3. changed the title [-]Page Nav[/-] [+]XDSPageNav (sidebar navigation)[/+] on Feb 19, 2026
  4. cixzhang commented on Feb 20, 2026

    @cixzhang
    ContributorAuthor

    For true internal usage we need to check internal component because this composes with built-in common data across tools. That usage is 4921 which is substantial.

  5. cixzhang commented on Feb 22, 2026

    @cixzhang
    ContributorAuthor

    Landed in PR #251 (XDSPageNav with header, items, and sections).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions