Documentation / Feedback & overlays
Toast
The notification message itself: a title, a text, a default icon per type (success, error, warning, info, neutral), three visual variants (soft by default, solid, outlined), a close button and an action slot. It carries role="alert".
Toast draws one message where it is rendered: duration calls onClose once the delay has passed (the countdown stops under the pointer and the focus), position fixes it to a corner of the screen. It does not stack and does not remove itself: removing it in onClose is up to you. For notifications pushed from anywhere, stacked and announced by one live region, mount a Toaster and call toast().
Examples
Basic usage
title and description (or children); closable={false} removes the cross.
import { Toast } from "@synertech/ui";
export function Basic() {
return (
<Toast
title="Modifications enregistrées"
description="Votre profil a été mis à jour."
type="success"
closable={false}
/>
);
}Types and variants
type picks the colour and the default icon, variant the strength of the background.
import { Toast } from "@synertech/ui";
export function TypesAndVariants() {
return (
<div className="grid gap-3">
<Toast type="info" title="Nouvelle version disponible" closable={false} />
<Toast type="success" variant="solid" title="Paiement reçu" closable={false} />
<Toast type="warning" variant="outlined" title="Stockage à 90 %" closable={false} />
<Toast
type="error"
variant="solid"
title="Échec de l’envoi"
description="Vérifiez votre connexion."
closable={false}
/>
</div>
);
}Action and custom icon
action holds a button (Undo, Retry…); icon replaces the type’s icon.
import { Button, Toast } from "@synertech/ui";
const TrashIcon = () => (
<svg
className="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
strokeWidth={2}
aria-hidden="true"
>
<path strokeLinecap="round" strokeLinejoin="round" d="M6 7h12M9 7V4h6v3m-8 0 1 13h8l1-13" />
</svg>
);
export function WithAction() {
return (
<Toast
title="Fichier supprimé"
description="rapport-mars.pdf a été placé dans la corbeille."
icon={<TrashIcon />}
onClose={() => console.log("Fermé")}
action={
<Button size="sm" onClick={() => console.log("Restauré")}>
Annuler
</Button>
}
/>
);
}Auto-dismiss
duration calls onClose after 4 seconds; the cross closes it sooner.
import { useState } from "react";
import { Button, Toast } from "@synertech/ui";
export function AutoDismiss() {
const [visible, setVisible] = useState(false);
return (
<div className="space-y-3">
<Button onClick={() => setVisible(true)}>Copier le lien</Button>
{visible && (
<Toast
type="success"
title="Lien copié dans le presse-papiers"
duration={4000}
onClose={() => setVisible(false)}
/>
)}
</div>
);
}API reference
Components
import { Toast } from "@synertech/ui";Props — ToastProps
| Prop | Type | Default | Description |
|---|---|---|---|
action |
ReactNode |
— | |
children |
ReactNode |
— | |
closable |
boolean |
true |
|
closeLabel |
string |
— | Accessible name of the close button. Defaults to the |
description |
ReactNode |
— | |
duration |
number |
— | Milliseconds after which |
icon |
ReactNode |
— | |
onClose |
() => void |
— | |
position |
ToastPosition |
— | Fixes the toast to that corner of the viewport, above dialogs and menus. Left out, the toast stays where it is rendered. One toast per corner: several with the same |
title |
ReactNode |
— | |
type |
ToastType |
"default" |
|
variant |
ToastVariant |
"soft" |
+ 277 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
Types
ToastPosition
Typetype ToastPosition = | "top-left"
| "top-center"
| "top-right"
| "bottom-left"
| "bottom-center"
| "bottom-right"ToastType
Typetype ToastType = "success" | "error" | "warning" | "info" | "default"ToastVariant
Typetype ToastVariant = "solid" | "outlined" | "soft"