Toast
A temporary notification component used to display feedback messages to the user.
Setup
Add the Toaster component to your root layout or a central component in your application.
layout.tsx
import { Toaster } from "@medway-ui/core";
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<main>{children}</main>
<Toaster />
</body>
</html>
);
}Examples
Primary
Preview
Secondary
Preview
Success
Preview
Warning
Preview
Error
Preview
With Action
Preview
Without Icon
Preview
Without Description
Preview
API
Toast
| Property | Type | Possible values | Default | Description |
|---|---|---|---|---|
| variant | ”primary” | “secondary” | “success” | “warning” | “error" | "primary”, “secondary”, “success”, “warning”, “error" | "primary” | Sets the visual style of the toast. |
| showIcon | boolean | true, false | true | Shows or hides the icon based on the variant. |
| duration | number | - | 5000 | Duration in milliseconds before the toast auto-closes. |
| className | string | - | - | Additional CSS classes for customization. |
ToastAction
| Property | Type | Possible values | Default | Description |
|---|---|---|---|---|
| variant | ”primary” | “secondary” | “success” | “warning” | “error" | "primary”, “secondary”, “success”, “warning”, “error" | "primary” | Sets the visual style of the action button. |
| altText | string | - | ”Toast action” | Alternative text for accessibility. |
| className | string | - | - | Additional CSS classes for customization. |
ToastClose
| Property | Type | Possible values | Default | Description |
|---|---|---|---|---|
| label | string | - | ”Close” | Accessible label for the close button. |
| className | string | - | - | Additional CSS classes for customization. |
Last updated on