Overlays
Toast
Short messages at the bottom. Place <Toaster /> once, in the root layout, and call toast() anywhere. A toast made while no Toaster is on the page is dropped.
import { Toaster, toast } from "@percentsa/ui";Examples
Code
export function ToastExample() {
const t = useT();
return (
<Inline gap={3}>
<Button variant="secondary" onClick={() => toast({ title: t("Saved", "تم الحفظ"), tone: "success" })}>
{t("Success", "نجاح")}
</Button>
<Button
variant="secondary"
onClick={() => toast({ title: t("Upload failed", "فشل الرفع"), description: t("Check your connection.", "تحقق من الاتصال."), tone: "danger" })}
>
{t("Error", "خطأ")}
</Button>
<Button
variant="secondary"
onClick={() =>
toast({
title: t("Message deleted", "حُذفت الرسالة"),
action: { label: t("Undo", "تراجع"), onClick: () => toast({ title: t("Message restored", "استُعيدت الرسالة") }) },
})
}
>
{t("With Undo", "مع تراجع")}
</Button>
</Inline>
);
}