Skip to content

feat(theme): add accordion mode for sidebar#3074

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/add-accordion-mode-sidebar
Draft

feat(theme): add accordion mode for sidebar#3074
Copilot wants to merge 4 commits into
mainfrom
copilot/add-accordion-mode-sidebar

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 29, 2026

Adds sidebar.accordion option to collapse sibling sections when expanding a top-level sidebar group, keeping documentation sidebars compact for sites with many sections.

Changes

  • Type definitions: Added accordion?: boolean to Sidebar and NormalizedSidebar interfaces
  • Normalization: Preserve accordion flag through config normalization, filter it from path matching
  • Component behavior: Modified SidebarGroup.toggleCollapse() to collapse sibling top-level groups when accordion enabled
    • Only affects depth-0 groups
    • Respects collapsible: false flag

Usage

export default defineConfig({
  themeConfig: {
    sidebar: {
      accordion: true,
      '/': [
        { text: 'Guide', items: [...] },
        { text: 'API Reference', items: [...] }
      ]
    }
  }
});

Screenshots

Initial state with all sections expanded:
Initial state

Accordion mode - only Guide section expanded:
Guide expanded

Accordion mode - only API Reference section expanded:
API expanded

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: Accordion mode for sidebar (single section expanded at a time)</issue_title>
<issue_description>### What problem does this feature solve?

It would be useful to have an option for accordion-style sidebar behavior where expanding one section automatically collapses others.

For documentation sites with many sidebar sections (e.g., multiple products or large changelogs), the sidebar can become very long when multiple sections are expanded. Accordion mode would keep the sidebar compact and focused.

What does the proposed API look like?

  // In rspress.config.ts
  themeConfig: {
    sidebar: {
      accordion: true, // Only one section expanded at a time
    }
  }

…or per-path:

  sidebar: {
    '/docs/': {
      accordion: true,
      items: [...]
    }
  }

Alternatives considered:

  • CSS/JS manipulation in custom theme - doesn't persist because Rspress manages sidebar state internally
  • Always starting sections collapsed (collapsed: true) - requires manual expand each time, poor UX

Prior art:

<agent_instructions>修改 useSidebarDynamic 并实现这个 accordion,仅实现

sidebar: {
accordion: true
}</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ization

Co-authored-by: SoonIter <79413249+SoonIter@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jan 29, 2026

Deploying rspress-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 246396a
Status:🚫  Build failed.

View logs

Copilot AI and others added 2 commits January 29, 2026 13:43
- Pass accordion config from Sidebar to SidebarGroup components
- Modify toggleCollapse to collapse sibling sections in accordion mode
- Add e2e test fixture for accordion mode
- Accordion only affects top-level sidebar groups

Co-authored-by: SoonIter <79413249+SoonIter@users.noreply.github.com>
- Add missing markdown files for advanced section
- Check collapsible flag before collapsing siblings in accordion mode
- Run auto-formatter to fix linting issues

Co-authored-by: SoonIter <79413249+SoonIter@users.noreply.github.com>
Copilot AI changed the title [WIP] Add accordion mode for sidebar navigation feat(theme): add accordion mode for sidebar Jan 29, 2026
Copilot AI requested a review from SoonIter January 29, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Accordion mode for sidebar (single section expanded at a time)

2 participants