Skip to content

Add afterNavSlot and footerSlot to SidebarNav #275

Description

@zoharma

What is being proposed?

Two new optional slot props on SidebarNav: afterNavSlot and footerSlot let consumers inject arbitrary content into the sidebar drawer alongside the generated navigation items. afterNavSlot renders inside the scrollable nav area, right after the last item; footerSlot is pinned to the bottom of the drawer, outside the scroll area, separated by a divider.

Why is this needed?

Today SidebarNav only renders items from the navigation prop, and there's no supported way to add content that isn't a generated nav item, e.g. a "Documentation" link, a "Stop all" button, a settings shortcut, or a user/account menu pinned to the bottom of the sidebar. Consumers would have to fork or wrap the component to achieve this.

What will change?

  • Behaviour: Additive only, existing usage is unaffected. Also fixes the label-wrapping and full-height drawer issues described above.
  • Component props: SidebarNav gains two new optional props, afterNavSlot?: ReactNode and footerSlot?: ReactNode.
  • New component: No.
  • Docs/stories: Added a WithSlots story demonstrating both slots, and made the existing NormalLinks/RouterLinks stories interactive (open/close toggle) for consistency with the other stories.

Interface changes (if any)

<SidebarNav
  navigation={navigation}
  open={open}
  setOpen={setOpen}
  afterNavSlot={<DocsLink />}
  footerSlot={<UserMenu />}
/>

Breaking change?

  • Yes
  • No

Next steps

A maintainer will review this issue.
If accepted, it will be marked as accepted and a PR may then be opened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageThis issue needs to be categorised. E.g. accepted, duplicate, wont-do

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions