WlAlert

An inline notification. The icon follows tone; a title and close button can be added independently.
Components / Feedback v0.1.0

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

tone

Semantic notification color.

live

Announcement priority: determined by tone, polite, assertive, or off for a static block.

title

Title.

closeLabel

Uses locale.close when omitted or undefined; English fallback: Close.

Button that closes the surface.

Props pt, models, handlers and slots can be edited in the SFC. See their descriptions in API.

Example

Changes saved
You can continue working.
Focus: outside the example · pointer: outside the example

Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.

Code for your application

Vue SFC · current settings
<script setup lang="ts">
import { WlAlert, WlButton } from "legato-ui";
import { ref } from "vue";
const visible = ref(true);
</script>

<template>
  <div class="wl-stack" data-space="md">
    <WlAlert
      v-if="visible"
      title="Changes saved"
      closable
      
      @close="visible = false"
    >{{ "You can continue working." }}<template #action>
      <WlButton size="sm" variant="ghost" @click="visible = false">{{ "Got it" }}</WlButton>
    </template></WlAlert>
    <WlButton v-else @click="visible = true">{{ "Show notification" }}</WlButton>
  </div>
</template>

Semantic tones and retry

Info/ok/warn/err, action slot, closable with a clear label and restoring a hidden error.

Tip
Your application saves the settings.
Saved
All changes are recorded in the local example.

Checks in this example: 0. Error: visible.

Vue SFC · additional example
<script setup lang="ts">
import { WlAlert, WlButton } from "legato-ui";
import { nextTick, ref } from "vue";
const error = ref(true);
const attempts = ref(0);
const errorRegion = ref<HTMLElement | null>(null);
async function showError(visible: boolean, retry = false): Promise<void> {
  if (retry) attempts.value++;
  error.value = visible;
  await nextTick();
  errorRegion.value?.querySelector<HTMLButtonElement>("button")?.focus();
}
</script>

<template>
  <div class="wl-stack" data-space="lg">
    <WlAlert tone="info" title="Tip">{{ "Your application saves the settings." }}</WlAlert>
    <WlAlert tone="success" title="Saved">{{
      "All changes are recorded in the local example."
    }}</WlAlert>
    <WlAlert tone="warning" title="Low on space">
      {{ "Free up space before adding another attachment." }}
      <template #action>
        <WlButton size="sm" @click="attempts++">{{ "Check space" }}</WlButton>
      </template>
    </WlAlert>
    <div ref="errorRegion">
      <WlAlert
        v-if="error"
        tone="danger"
        title="Could not save"
        closable
        close-label="Hide error message"
        @close="showError(false)"
      >
        {{ "The draft is saved. Try again." }}
        <template #action>
          <WlButton size="sm" @click="showError(false, true)">{{ "Retry saving" }}</WlButton>
        </template>
      </WlAlert>
      <div v-else>
        <WlButton size="sm" variant="soft" @click="showError(true)">{{ "Show error again" }}</WlButton>
      </div>
    </div>
    <p class="wl-text-small" role="status">
      {{ "Checks in this example:" }} {{ attempts }}{{ ". Error:" }}
      {{ error ? "visible" : "hidden" }}.
    </p>
  </div>
</template>