Docs
Toast
Toast
Inform users of a process that an app has performed or will perform.
Installation
npm install @brudi/react-toast
Toaster
Add the <Toaster />
component to your app.
The <Toaster />
component is where your toasts are displayed. You can place it anywhere in your app, but it's recommended to place it at the root of your app.
Pages
_app.tsx
import { Toaster } from '@brudi/react-toast'
export default function App({ Component, pageProps }) {
return (
<>
<Component {...pageProps} />
<Toaster />
</>
)
}
App Directory
app/layout.tsx
import { Toaster } from '@brudi/react-toast'
export default function RootLayout({ children }) {
return (
<html lang="en">
<head />
<body>
<main>{children}</main>
<Toaster />
</body>
</html>
)
}
Usage
Use the toast
function to display a toast.
import { toast } from '@brudi/react-toast'
export const ToastDemo = () => {
return (
<Button
onClick={() => {
toast({
title: 'Note archived',
description: 'Wednsday, January 03, 2024 at 11:42 AM'
})
}}
>
Show Toast
</Button>
)
}
Examples
Simple
With title
Variants
Use toast({ variant: "destructive" }})
to display a destructive toast.
Customization
npx @brudi/ui extend toast