Toast
Short, temporary notification message for action results or errors.
Last updated 11/1/2024
Variants
Choose among three types based on meaning and importance. You can set the duration before the toast disappears; see sample code for details.
- Default
- Success
- Error
import { Button, Toast, toaster } from "@serendie/ui";
import { Dd, Dl, Dt } from "src/components/LayoutUtils";
export function ToastSample() {
return (
<Dl>
<Dt>Default</Dt>
<Dd>
<Button
styleType="outlined"
onClick={() =>
toaster.create({
title: "お知らせメッセージ",
duration: 1500,
})
}
>
Show Toast
</Button>
<Toast toaster={toaster} />
</Dd>
<Dt>Success</Dt>
<Dd>
<Button
styleType="outlined"
onClick={() =>
toaster.create({
type: "success",
title: "成功しました",
duration: 1500,
})
}
>
Show Toast
</Button>
<Toast toaster={toaster} />
</Dd>
<Dt>Error</Dt>
<Dd>
<Button
styleType="outlined"
onClick={() =>
toaster.create({
type: "error",
title: "エラーがあります",
duration: 1500,
})
}
>
Show Toast
</Button>
<Toast toaster={toaster} />
</Dd>
</Dl>
);
}