qat

Toast

Toaster. It is copied into your app’s ui/ by qatjs add toast: the code is yours to edit.

Example

Undone 0 times

Example.qx31 lines, 1 reactive nameOpen in the playground
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 state

Add it

shell1 line
npx qatjs add toast

Toaster

Where the toasts show: the last three, the newest at the bottom. As a custom element: <ui-toaster>.

Toaster: props
PropTypeAttribute
labelstringyes

Keys

KeyDoes
Tabto the toast’s action