Usage
import { useToast } from "@smartacteam/ambient-web/toaster";export const ToastDemo = () => {
const toast = useToast();
return (
<Button
onClick={() => {
toast({
title: "Scheduled: Catch up",
description: "Friday, February 10, 2023 at 5:57 PM",
});
}}
>
Show Toast
</Button>
);
};Variants
The toast component supports five variants: default, info, success, warning, and error. Each variant uses different colors and is appropriate for different types of notifications. When demonstrating multiple variants at once, give every Toast.Root its own state so triggering one toast does not unintentionally toggle the others. A Toast.Root with no variant renders as default.
A primary Button inside a status toast takes the toast's tint, two steps up its color scale, the way one inside an Alert does. The variant's icon color reaches only the icon in Toast.Title, so buttons and the close control keep their own icon colors.