Docs
Toast
Toast
A succinct message that is displayed temporarily.
(!) Pre-requisites
The <Toaster />
component must first be added to your project root.
This only needs to be done once so all the toast messages know where to appear.
import { Toaster } from '~/registry/ui/toaster'
...
export default function RootLayout({ children }) {
return (
<html lang="en">
<head />
<body>
<main>{children}</main>
<Toaster />
</body>
</html>
)
}
Usage
import { Button, ToastAction, useToast } from '@bit/ui'
const { toast } = useToast()
return (
<Button
variant='outline'
onClick={() =>
toast({
title: 'Scheduled: Catch up',
description: 'Friday, February 10, 2023 at 5:57 PM',
action: <Toast.Action altText='Goto schedule to undo'>Undo</Toast.Action>,
})
}
>
Show Toast
</Button>
)