RightPanel

Panel with a header and scrolling body for the AppShell right panel

Installation

pnpm add @wandercom/design-system-web

Usage

RightPanel is the content of AppShell's right panel, such as Ask Wander or Help. It's built from PageShell, so its radius, border, fill, header and scrolling body match the canvas. It has no content of its own.

18 lines
import { RightPanel } from '@wandercom/design-system-web/blocks/right-panel';
import { DropdownItem } from '@wandercom/design-system-web/ui/dropdown';

<AppShell.Panel>
  <RightPanel>
    <RightPanel.Header>
      <RightPanel.Back onClick={showList} />
      <RightPanel.Title icon={<IconHelp />}>Help</RightPanel.Title>
      <RightPanel.Actions>
        <RightPanel.MoreMenu>
          <DropdownItem>Contact support</DropdownItem>
        </RightPanel.MoreMenu>
      </RightPanel.Actions>
      <RightPanel.Close />
    </RightPanel.Header>
    <RightPanel.Body>…</RightPanel.Body>
  </RightPanel>
</AppShell.Panel>

The parts are also available as RightPanelHeader, RightPanelBack, RightPanelTitle, RightPanelActions, RightPanelMoreMenu, RightPanelClose and RightPanelBody.

Loading example...

The header holds, in order: an optional back button for nested views, the title with an optional icon, optional actions such as a ••• menu, and the close button.

The title renders an h2, since the canvas holds the page's h1. The panel is labelled by its title.

Inside AppShell, RightPanel.Close closes the panel by calling onPanelOpenChange(false). Call event.preventDefault() in its onClick to keep the panel open, such as to confirm discarding a draft. Outside AppShell, handle onClick yourself.

Body

The body scrolls separately from the canvas, and a divider appears under the header once it scrolls, like PageShellBody. For content that scrolls itself, such as ChatComposed, give the body overflow-hidden.

Props

RightPanel.Title

icon?:

React.ReactNode
Icon shown before the title.

RightPanel.Back

onClick?:

(event: React.MouseEvent) => void
Called when the button is clicked.

href?:

string
Renders an anchor to this URL.

asChild?:

boolean
Renders the child element, such as a router link.

label?:

string
Accessible name for the button. Defaults to "Back".

RightPanel.Close

onClick?:

(event: React.MouseEvent) => void
Called before the panel closes. Call event.preventDefault() to keep it open.

label?:

string
Accessible name for the button. Defaults to "Close panel".

RightPanel.MoreMenu

children:

React.ReactNode
DropdownItem or DropdownLinkItem elements.

label?:

string
Accessible name for the trigger. Defaults to "More panel options".
RightPanel