-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73f4cf7
commit 9e0b577
Showing
31 changed files
with
16,913 additions
and
8,596 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,10 +1,18 @@ | ||
/** @type {import('next').NextConfig} */ | ||
|
||
module.exports = { | ||
const withNextra = require("nextra")({ | ||
theme: "nextra-theme-docs", | ||
themeConfig: "./theme.config.jsx", | ||
}); | ||
|
||
module.exports = withNextra({ | ||
reactStrictMode: true, | ||
output: "export", | ||
transpilePackages: ["mui-sonner"], | ||
images: { | ||
unoptimized: true, | ||
}, | ||
}; | ||
}); | ||
|
||
// If you have other Next.js configurations, you can pass them as the parameter: | ||
// module.exports = withNextra({ /* other next.js config */ }) |
This file contains 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 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 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,27 @@ | ||
{ | ||
"getting-started": { | ||
"title": "Getting Started", | ||
"href": "/getting-started" | ||
|
||
}, | ||
"-- API": { | ||
"type": "separator", | ||
"title": "API" | ||
}, | ||
"toast": { | ||
"title": "toast()", | ||
"href": "/toast" | ||
}, | ||
"toaster": { | ||
"title": "Toaster", | ||
"href": "/toaster" | ||
}, | ||
"-- More": { | ||
"type": "separator", | ||
"title": "Guides" | ||
}, | ||
"styling": { | ||
"title": "Styling", | ||
"href": "/styling" | ||
} | ||
} |
This file contains 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,72 @@ | ||
import { Tab, Tabs, Cards, Card, Steps } from "nextra-theme-docs"; | ||
import { toast } from "mui-sonner"; | ||
|
||
# Getting Started | ||
|
||
MUI Sonner is an opinionated toast component for MUI & React. | ||
|
||
<Steps> | ||
### Install | ||
|
||
<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}> | ||
<Tab> | ||
```bash | ||
pnpm i mui-sonner | ||
``` | ||
|
||
</Tab> | ||
<Tab> | ||
```bash | ||
npm i mui-sonner | ||
``` | ||
</Tab> | ||
<Tab> | ||
```bash | ||
yarn add mui-sonner | ||
``` | ||
</Tab> | ||
<Tab> | ||
```bash | ||
bun add mui-sonner | ||
``` | ||
</Tab> | ||
</Tabs> | ||
|
||
### Add Toaster to your app | ||
|
||
It can be placed anywhere, but it's recommended to place higher up the component tree. | ||
```tsx | ||
import { Toaster } from "mui-sonner"; | ||
export default function App({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<html lang="en"> | ||
<body> | ||
{children} | ||
<Toaster /> | ||
</body> | ||
</html> | ||
); | ||
} | ||
``` | ||
### Render a toast | ||
```tsx | ||
import { toast } from "mui-sonner"; | ||
const MyToast = () => { | ||
return ( | ||
<button onClick={() => toast("Hello World")}> | ||
Render my toast | ||
</button> | ||
) | ||
} | ||
``` | ||
</Steps> |
This file contains 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,112 @@ | ||
import { Callout } from 'nextra/components' | ||
|
||
# Styling | ||
|
||
Styling can be done in a few different ways. We will run through all the options here. | ||
|
||
## Styling with the MUI Theme | ||
Styling can be done globally via the MUI theme. This way every toast will have the same styling. | ||
|
||
MUI lets you target the different variants of the toast, so you can style them differently. | ||
|
||
For example you can style all the filled success toasts to have a red background color. | ||
|
||
```jsx | ||
const theme = createTheme({ | ||
components: { | ||
MuiAlert: { | ||
styleOverrides: { | ||
filledSuccess: { | ||
backgroundColor: "red", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
<Callout type="warning" emoji="⚠️">This will change the styling of all the `Alert` components in your app, not just the toasts.</Callout> | ||
|
||
Check out the [MUI documentation](https://mui.com/customization/theming/) for more information on theming. | ||
- [Alert](https://mui.com/material-ui/api/alert/) | ||
- [AlertTitle](https://mui.com/material-ui/api/alert-title/) | ||
|
||
## Styling with the Toaster | ||
|
||
Styling can be done globally via `toastOptions`, this way every toast will have the same styling. | ||
- You can style the `Alert` component for all toasts | ||
- You can style the `CloseButton` `ActionButton` and `Description` for all different types of toasts. | ||
|
||
```jsx | ||
<Toaster | ||
toastOptions={{ | ||
alertSx: { | ||
backgroundColor: "red", | ||
}, | ||
success:{ | ||
closeButtonSx: { | ||
color: "red", | ||
} | ||
actionButtonSx: { | ||
color: "red", | ||
} | ||
descriptionSx: { | ||
color: "red", | ||
} | ||
}, | ||
loading:{ | ||
closeButtonSx: { | ||
color: "red", | ||
} | ||
actionButtonSx: { | ||
color: "red", | ||
} | ||
descriptionSx: { | ||
color: "red", | ||
} | ||
} | ||
// ... and so on | ||
}} | ||
/> | ||
``` | ||
## Styling with the toast | ||
You can also use the same props when calling `toast` to style a specific toast. | ||
|
||
```jsx | ||
toast('Hello World', { | ||
}); | ||
``` | ||
|
||
## Changing Icons | ||
|
||
You can change the default icons using the `toasterOptions` on the `Toaster` component. This will change the default icons for all toasts, for their respective toast types. | ||
|
||
```jsx | ||
<Toaster | ||
toasterOptions={{ | ||
success: { | ||
icon: <SuccessIcon/> | ||
}, | ||
info: { | ||
icon: <InfoIcon/> | ||
}, | ||
// ... and so on | ||
}} | ||
/> | ||
``` | ||
|
||
You can also set an icon for each toast: | ||
|
||
```jsx | ||
toast('Hello World', { | ||
icon: <Icon />, | ||
}); | ||
``` | ||
|
||
You can also set a toast to hide the icon: | ||
|
||
```jsx | ||
toast('Hello World', { | ||
hideIcon: true, | ||
}); | ||
``` |
Oops, something went wrong.