Products · Components

Toast

A short message that shows over the page for a moment, such as "Copied".

Keep one Toast on the page and set message to show it. To show the same text twice, clear message in onHide.

Children: Nothing

Example

The Toast component
view.dml
<View>
  <Button variant="secondary" onClick="copy">Copy reference</Button>
  <Toast message="{{ toast }}" tone="success" onHide="clearToast" />
</View>
controller.ts
export default definePage({
  initialState: { toast: '' },
  mutations: {
    copy: () => ({ toast: 'Copied' }),
    clearToast: () => ({ toast: '' }),
  },
});

Props

PropTypeWhat it is
messagestringThe text to show. The toast shows each time it changes.
tonestatus toneDefault: default.
durationnumberIn milliseconds. Default: 2500.

Events

EventSendsNotes
onHideNothingThe toast hid.

Keep reading

On this page