diff --git a/docs/data/toolpad/core/components/app-provider/app-provider.md b/docs/data/toolpad/core/components/app-provider/app-provider.md index 62b4b38b6e9..bffc6d437fd 100644 --- a/docs/data/toolpad/core/components/app-provider/app-provider.md +++ b/docs/data/toolpad/core/components/app-provider/app-provider.md @@ -31,8 +31,6 @@ The `AppProvider` for Next.js applications includes some Next.js integrations ou By using the specific `AppProvider` for Next.js you do not have to manually configure the integration between some Toolpad features and the corresponding Next.js features (such as routing), making the integration automatic and seamless. ```tsx -import { AppProvider } from '@toolpad/core/nextjs/AppProvider'; -// or import { AppProvider } from '@toolpad/core/nextjs'; ``` @@ -43,7 +41,7 @@ When using the **Next.js App Router**, the most typical file where to import and ```tsx // app/layout.tsx -import { AppProvider } from '@toolpad/core/nextjs/AppProvider'; +import { AppProvider } from '@toolpad/core/nextjs'; export default function Layout(props) { const { children } = props; @@ -65,7 +63,7 @@ When using the **Next.js Pages Router**, the most typical file where to import a ```tsx // pages/_app.tsx -import { AppProvider } from '@toolpad/core/nextjs/AppProvider'; +import { AppProvider } from '@toolpad/core/nextjs'; export default function App(props) { const { Component, pageProps } = props; @@ -78,6 +76,16 @@ export default function App(props) { } ``` +## Client-side Routing + +The `AppProvider` for React Router includes routing out-of-the-box for projects using [react-router-dom](https://www.npmjs.com/package/react-router-dom). + +This specific `AppProvider` is recommended when building single-page applications with tools such as [Vite](https://vite.dev/), as you do not have to manually configure your app routing, making the integration automatic and seamless. + +```tsx +import { AppProvider } from '@toolpad/core/react-router-dom'; +``` + ## Theming An `AppProvider` can set a visual theme for all elements inside it to adopt via the `theme` prop. This prop can be set in a few distinct ways with different advantages and disadvantages: diff --git a/docs/data/toolpad/core/components/dashboard-layout/DashboardLayoutFullScreen.js b/docs/data/toolpad/core/components/dashboard-layout/DashboardLayoutFullScreen.js new file mode 100644 index 00000000000..2f71df3e348 --- /dev/null +++ b/docs/data/toolpad/core/components/dashboard-layout/DashboardLayoutFullScreen.js @@ -0,0 +1,76 @@ +import * as React from 'react'; +import PropTypes from 'prop-types'; +import { createTheme } from '@mui/material/styles'; +import MapIcon from '@mui/icons-material/Map'; +import { AppProvider } from '@toolpad/core/AppProvider'; +import { DashboardLayout } from '@toolpad/core/DashboardLayout'; + +const NAVIGATION = [ + { + segment: 'map', + title: 'Map', + icon: , + }, +]; + +const demoTheme = createTheme({ + cssVariables: { + colorSchemeSelector: 'data-toolpad-color-scheme', + }, + colorSchemes: { light: true, dark: true }, + breakpoints: { + values: { + xs: 0, + sm: 600, + md: 600, + lg: 1200, + xl: 1536, + }, + }, +}); + +function DashboardLayoutFullScreen(props) { + const { window } = props; + + const [pathname, setPathname] = React.useState('/map'); + + const router = React.useMemo(() => { + return { + pathname, + searchParams: new URLSearchParams(), + navigate: (path) => setPathname(String(path)), + }; + }, [pathname]); + + // Remove this const when copying and pasting into your project. + const demoWindow = window !== undefined ? window() : undefined; + + return ( + + +