Skip to content
+

Page Container

A component that wraps page content and provides a title, breadcrumbs, and page actions.

PageContainer is the ideal wrapper for the content of your dashboard. It shows the current page title, and provides breadcrumbs to navigate back into the current hierarchy. It makes your page responsive through the use of the Material UI Container component under the hood.

Just like DashboardLayout, PageContainer uses the navigation structure that is defined in the AppProvider to build up its breadcrumbs and title.

Orders

Page content
Press Enter to start editing

Title and Breadcrumbs

The breacrumbs are formed by matching the current pathname with the navigation structure defined in the AppProvider. The title of the matched segment is used as the page title. You can override the page title with the title property.

For example, under the following navigation structure:

<AppProvider
  navigation={[
    {
      segment: 'home',
      title: 'Home',
      children: [
        {
          segment: 'orders',
          title: 'Orders',
        },
      ],
    },
  ]}
>
  ...
</AppProvider>

The breadcrumbs contains ACME / Home / Orders when you visit the path /home/orders, and the page has a title of Orders.

Orders

Dynamic Routes

When you use the PageContainer on a dynamic route, you'll likely want to set a title and breadcrumbs belonging to the specific path. You can achieve this with the title and breadcrumbs property of the PageContainer

Item 123

Press Enter to start editing

You can use the useActivePage hook to retrieve the title and breadcrumbs of the active page. This way you can extend the existing values.

import { useActivePage } from '@toolpad/core/useActivePage';
import { Breadcrumb } from '@toolpad/core/PageContainer';

// Pass the id from your router of choice
function useDynamicBreadcrumbs(id: string): Breadcrumb[] {
  const activePage = useActivePage();
  invariant(activePage, 'No navigation match');

  const title = `Item ${id}`;
  const path = `${activePage.path}/${id}`;

  return [...activePage.breadcrumbs, { title, path }];
}

For example, under the Next.js app router you would be able to obtain breadcrumbs for a dynamic route as follows:

// ./src/app/example/[id]/page.tsx
'use client';

import { useParams } from 'next/navigation';
import { PageContainer } from '@toolpad/core/PageContainer';
import invariant from 'invariant';
import { useActivePage } from '@toolpad/core/useActivePage';

export default function Example() {
  const params = useParams<{ id: string }>();
  const activePage = useActivePage();
  invariant(activePage, 'No navigation match');

  const title = `Item ${params.id}`;
  const path = `${activePage.path}/${params.id}`;

  const breadcrumbs = [...activePage.breadcrumbs, { title, path }];

  return (
    <PageContainer title={title} breadcrumbs={breadcrumbs}>
      ...
    </PageContainer>
  );
}

Actions

You can configure additional actions in the area that is reserved on the right. To do so provide the toolbar slot to the PageContainer component. You can wrap the PageContainerToolbar component to create a custom toolbar component, as shown here:

Weather

Temperature

24°C

Precipitation

5%

Wind

18km/h

Press Enter to start editing

Responsiveness

The Page Container component inherits the properties of the Material UI Container component. You can use its maxWidth and fixed properties to control the bounds of the page. Set maxWidth to false to disable the container altogether and have the content bleed right up to the edges of the page.

API

See the documentation below for a complete reference to all of the props and classes available to the components mentioned here.