Toast
Toaster. It is copied into your app’s ui/ by qatjs add toast: the code is yours to edit.
Example
Undone 0 times
import Button from './ui/button/button.qx'
import { Toaster, toast } from './ui/toast/toast.qx'
export default function Example() {
let undone = state(0)
return (
<div class="example-row">
<Button
on:click={() =>
toast({
title: 'Order saved',
body: 'The customer got an SMS.',
kind: 'success',
action: { label: 'Undo', run: () => undone++ },
})
}
>
Show a toast
</Button>
<Button
on:click={() => toast({ title: 'Couldn’t refund', body: 'The provider timed out.', kind: 'error' })}
>
Show an error
</Button>
</div>
<p>Undone {undone} times</p>
<Toaster />
)
}undone stateAdd it
npx qatjs add toastToaster
Where the toasts show: the last three, the newest at the bottom. As a custom element: <ui-toaster>.
| Prop | Type | Attribute |
|---|---|---|
label | string | yes |
Keys
| Key | Does |
|---|---|
| Tab | to the toast’s action |