Feedback
Toast
A short message that comes and goes by itself: a change saved, an upload done.
Installation
pnpm add @elsikora/keystone-ui-kitUsage
import { Toast, ToastAction } from "@elsikora/keystone-ui-kit";import { useState } from "react";import { Button, Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport,} from "@elsikora/keystone-ui-kit";
export default function ToastDefaultExample() { const [open, setOpen] = useState<boolean>(false);
return ( <ToastProvider> <Button variant="outline" onClick={(): void => { setOpen(true); }} > Save </Button> <Toast open={open} onOpenChange={setOpen}> <ToastTitle>Saved</ToastTitle> <ToastDescription>The limits apply to new rounds.</ToastDescription> <ToastClose /> </Toast> <ToastViewport /> </ToastProvider> );}Examples
Default
Failure
API reference
Toast
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "destructive" | "default" | A failure is announced at once. |
open | boolean | - | Shown, when the caller holds the state. |
onOpenChange | (open: boolean) => void | - | Called when it shows or goes. |
duration | number | 5000 | Milliseconds before it goes. |
ToastAction
| Prop | Type | Default | Description |
|---|---|---|---|
altText | string | - | How to do the same without the toast. |
Notes
- F8 moves the focus to the toasts; Escape closes one. Never put the only way to do something in a toast.