-
-
Notifications
You must be signed in to change notification settings - Fork 401
[docs] Add integration, base concepts #4080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bharatkashyap
merged 30 commits into
mui:master
from
bharatkashyap:docs/integration-base-concepts
Sep 20, 2024
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
aa2b060
docs: Add integration, base concepts
bharatkashyap b3eab0b
fix: Why
bharatkashyap 0707dcd
fix: Add `pages` router and images
bharatkashyap e69e9f8
fix: Add callout to base concepts on demo pages
bharatkashyap 9fc9e35
Merge branch 'master' into docs/integration-base-concepts
bharatkashyap 4e5bb30
Merge branch 'master' into docs/integration-base-concepts
bharatkashyap fd6e9c5
fix: `markdownlint`
bharatkashyap 9242e60
Merge branch 'master' into docs/integration-base-concepts
bharatkashyap 7390686
Update docs/data/toolpad/core/introduction/base-concepts.md
bharatkashyap 04aae8a
Update docs/data/toolpad/core/introduction/base-concepts.md
bharatkashyap ebfd494
Merge branch 'master' into docs/integration-base-concepts
bharatkashyap 44cb7ab
fix: Typo
bharatkashyap 22623b9
fix: Make `AppProvider` props section leaner
bharatkashyap 5c61022
Update docs/data/toolpad/core/introduction/base-concepts.md
bharatkashyap ec87f74
Update docs/data/toolpad/core/pages.ts
bharatkashyap 0b586a2
Update docs/data/toolpad/core/introduction/base-concepts.md
bharatkashyap 3c9e8e6
Update docs/data/toolpad/core/introduction/integration.md
bharatkashyap 420cfdc
Update docs/data/toolpad/core/introduction/integration.md
bharatkashyap d95c67b
Merge branch 'master' of github.com:mui/mui-toolpad into docs/integra…
bharatkashyap d5f86a3
fix: Review
bharatkashyap 4a2090e
Merge branch 'master' of github.com:mui/mui-toolpad into docs/integra…
bharatkashyap 9b8ce2f
Update docs/data/toolpad/core/components/persistent-state/persistent-…
bharatkashyap 8d523d6
Update docs/data/toolpad/core/components/account/account.md
bharatkashyap 2f5ce91
fix: Jan review
bharatkashyap f1d721e
Merge branch 'master' of github.com:mui/mui-toolpad into docs/integra…
bharatkashyap bfe7258
fix: CI
bharatkashyap 9e654e8
fix: Use `success` instead
bharatkashyap 87931b1
Merge branch 'master' into docs/integration-base-concepts
bharatkashyap 9b780e6
Merge branch 'master' into docs/integration-base-concepts
bharatkashyap d2e1106
Merge branch 'master' into docs/integration-base-concepts
bharatkashyap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| --- | ||
| title: Toolpad Core - Base Concepts | ||
| --- | ||
|
|
||
| # Base concepts | ||
|
|
||
| <p class="description">Understand the fundamental concepts of Toolpad Core to effectively integrate and use it in your projects.</p> | ||
|
|
||
| ## Imports | ||
|
|
||
| Toolpad Core components can be imported directly from the `@toolpad/core` package. This allows you to use them alongside your existing Material UI or other components. | ||
|
|
||
| ```tsx | ||
| import Button from '@mui/material/Button'; | ||
| import { DashboardLayout } from '@toolpad/core/DashboardLayout'; | ||
| ``` | ||
|
|
||
| ## Component Hierarchy | ||
|
|
||
| The Toolpad Core library is designed to work under different React runtimes such as Next.js, Vite, or even your custom setup. Many of its components rely on functionality of the specific runtime they are used under. The key component in making the components runtime-aware is the `AppProvider`. | ||
|
|
||
| ### App Provider | ||
|
|
||
| The `AppProvider` acts as a bridge between your application's runtime and Toolpad components. It should wrap your entire application or the part of your application where you want to use Toolpad components. | ||
|
|
||
| ```tsx | ||
| import { AppProvider } from '@toolpad/core/AppProvider'; | ||
|
|
||
| function MyApp({ Component, pageProps }) { | ||
| return ( | ||
| <AppProvider> | ||
| <Component {...pageProps} /> | ||
| </AppProvider> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| By wrapping your application with `AppProvider`, you ensure that all other Toolpad components you use have access to the necessary context and functionality. | ||
|
|
||
| The `AppProvider` component accepts props to configure the app's navigation, theme, branding, router, authentication, and session, like so: | ||
|
|
||
| ```tsx | ||
| <AppProvider | ||
| navigation={NAVIGATION} | ||
| theme={theme} | ||
| branding={BRANDING} | ||
| router={router} | ||
| authentication={AUTHENTICATION} | ||
| session={session} | ||
| > | ||
| {props.children} | ||
| </AppProvider> | ||
| ``` | ||
|
|
||
| Head over to the [AppProvider](/toolpad/core/react-app-provider/) page for more details and examples of the usage of all props. | ||
|
|
||
| :::info | ||
| Toolpad Core doesn't handle routing itself. Instead, it's designed to integrate seamlessly with your existing routing solution, whether you're using: | ||
|
|
||
| - Next.js App Router | ||
| - Next.js Pages Router | ||
| - React Router | ||
| - Or any other routing library which implements the same interface | ||
|
|
||
| You can pass the router implementation to the `AppProvider` component using the `router` prop. | ||
|
|
||
| ::: | ||
|
|
||
| :::success | ||
| If you are using Next.js, use the `AppProvider` exported from `@toolpad/core/nextjs`. This automatically sets up the router for you and you do not need to pass the `router` prop. | ||
| ::: | ||
|
|
||
| ## Slots | ||
|
|
||
| Toolpad Core uses slots for component customization. Slots allow you to override specific parts of a component, providing flexibility in styling and functionality. You can also pass additional props to specific slots using the `slotProps` prop. | ||
|
|
||
| Here's an example using the `SignInPage` component: | ||
|
|
||
| ```tsx | ||
| import { SignInPage } from '@toolpad/core/SignInPage'; | ||
| function MyComponent() { | ||
| return ( | ||
| <SignInPage | ||
| slots={{ | ||
| emailField: CustomEmailField, | ||
|
|
||
| }} | ||
| slotProps={{ | ||
| passwordField: { | ||
| variant: 'outlined', | ||
| }, | ||
| }} | ||
| > | ||
| Custom Button | ||
| </Button> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| In this example: | ||
|
|
||
| - The `slots` prop allows you to replace entire parts of the component. | ||
| - The `slotProps` prop lets you pass additional props to specific slots. | ||
|
|
||
| ## Next Steps | ||
|
|
||
| Now that you understand the basic concepts of Toolpad Core, you're ready to start integrating it into your project. Head over to the [integration docs](/toolpad/core/introduction/integration/) to learn more. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can add that for Next.js you don't need to set this up yourself. We have an
AppProviderexported from@toolpad/core/nextjsthat already sets it up correctly.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could add it as a separate callout from this info callout and draw specific attention to the
@toolpad/core/nextjsexport