WlToast

Toast container with semantic tone. Display through useWlToast().show; existing methods and severity remain available.
Components / Feedback v0.1.0

Basic example

Full example
<div class="wl-stack" data-space="md">
  <!-- Mount WlToast once in the application root. -->
  <div class="wl-inline" data-space="sm">
    <WlButton @click="toast.show('Material saved', { tone: 'success' })">
      {{ "Success" }}
    </WlButton>
    <WlButton @click="toast.show('Could not save', { tone: 'danger', detail: 'Try again.' })">
      {{ "Error" }}
    </WlButton>
  </div>
</div>

Four notification types

useWlToast().show displays a semantic tone through the application's existing container; old helper methods remain supported.

Notifications shown: 0.

One application container receives all messages. Also show important errors near the affected field or action.

Full example
<script setup lang="ts">
import { useWlToast, WlButton, type WlTone } from "legato-ui";
import { ref } from "vue";
// Install WlToastService and mount one WlToast in the application root.
const toast = useWlToast();
const shown = ref(0);
function show(tone: WlTone): void {
  const messages: Record<WlTone, string> = {
    neutral: "Local example notification.", accent: "New version available",
    success: "Material saved", info: "New version available",
    warning: "Check available space", danger: "Could not save"
  };
  toast.show(messages[tone], {
    tone,
    detail: tone === "danger" ? "Draft saved. Try again." : "Local example notification."
  });
  shown.value++;
}
</script>

<template>
  <div class="wl-stack" data-space="lg">
    <div class="wl-inline" data-space="sm">
      <WlButton variant="soft" tone="neutral" @click="show('neutral')">neutral</WlButton>
      <WlButton variant="soft" tone="accent" @click="show('accent')">accent</WlButton>
      <WlButton variant="soft" tone="success" @click="show('success')">{{ "Show success" }}</WlButton>
      <WlButton variant="soft" tone="info" @click="show('info')">{{ "Show information" }}</WlButton>
      <WlButton variant="soft" tone="warning" @click="show('warning')">{{ "Show warning" }}</WlButton>
      <WlButton variant="ghost" tone="danger" @click="show('danger')">{{ "Show error" }}</WlButton>
    </div>
    <p class="wl-text-small" role="status">{{ "Notifications shown:" }} {{ shown }}.</p>
    <p class="wl-text-small wl-text-muted">{{ "One application container receives all messages. Also show important errors near the affected field or action." }}</p>
  </div>
</template>

Connecting the service

Register WlToastService with the Vue application and add one WlToast to App.vue. Each application has its own service state. Import styles as described in the installation section.

main.ts · service and container
import { createApp } from "vue";
import { WlToastService } from "legato-ui";
import App from "./App.vue";
const app = createApp(App);
app.use(WlToastService);
app.mount("#app");

// One container in the root App.vue: WlToast.
// import { WlToast } from "legato-ui";
// <WlToast />