Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Alert

    In-page message for important information, with info, success, warning, and danger variants.

    Update available

    Version 2.1 can be installed at any time.

    Update available

    Version 2.1 can be installed at any time.

    Alert

    <x-markas.alert variant="info" title="Heads up">You can add components to your app with the CLI.</x-markas.alert>
    import { Alert } from "@/components/markas/Alert";
    
    <Alert variant="info" title="Heads up">You can add components to your app with the CLI.</Alert>
    import Alert from "@/components/markas/Alert.vue";
    
    <Alert variant="info" title="Heads up">You can add components to your app with the CLI.</Alert>
    <script lang="ts">
      import Alert from "$lib/components/markas/Alert.svelte";
    </script>
    
    <div class="grid gap-3">
      <Alert title="Update available" role="status">
        Version 2.1 can be installed at any time.
      </Alert>
      <Alert variant="success" title="Payment received">
        The invoice has been sent to your email.
      </Alert>
      <Alert variant="warning" title="Quota almost full">
        Only 10% of your storage is left.
      </Alert>
      <Alert variant="danger" title="Could not save">
        Check your internet connection and try again.
      </Alert>
    </div>
    ---
    import Alert from "@/components/markas/Alert.astro";
    ---
    
    <div class="grid gap-3">
      <Alert title="Update available" role="status">
        Version 2.1 can be installed at any time.
      </Alert>
      <Alert variant="success" title="Payment received">
        The invoice has been sent to your email.
      </Alert>
      <Alert variant="warning" title="Quota almost full">
        Only 10% of your storage is left.
      </Alert>
      <Alert variant="danger" title="Could not save">
        Check your internet connection and try again.
      </Alert>
    </div>
    import { Component } from "@angular/core";
    import { Alert } from "./markas/alert.component";
    
    @Component({
      selector: "markas-example",
      imports: [Alert],
      template: `
        <div class="grid gap-3">
          <markas-alert title="Update available" role="status">
            Version 2.1 can be installed at any time.
          </markas-alert>
          <markas-alert variant="success" title="Payment received">
            The invoice has been sent to your email.
          </markas-alert>
          <markas-alert variant="warning" title="Quota almost full">
            Only 10% of your storage is left.
          </markas-alert>
          <markas-alert variant="danger" title="Could not save">
            Check your internet connection and try again.
          </markas-alert>
        </div>
      `,
    })
    export default class AlertExample {}

    Examples

    Without title

    Your changes are saved as a draft until you publish.
    Your changes are saved as a draft until you publish.
    Your changes are saved as a draft until you publish.
    Your changes are saved as a draft until you publish.
    Your changes are saved as a draft until you publish.

    With actions

    Error list

    In a card

    Delete workspace

    All projects, files, and members will be removed.

    Delete workspace

    All projects, files, and members will be removed.

    Delete workspace

    All projects, files, and members will be removed.

    Delete workspace

    All projects, files, and members will be removed.

    Delete workspace

    All projects, files, and members will be removed.

    Installation

    npx markasui@latest add alert

    Usage

    <x-markas.alert title="Update available" role="status">Version 2.1 can be installed at any time.</x-markas.alert>
    <x-markas.alert variant="danger" title="Could not save">Check your internet connection and try again.</x-markas.alert>
    import { Alert } from "@/components/markas/Alert";
    
    <Alert title="Update available" role="status">
      Version 2.1 can be installed at any time.
    </Alert>
    <Alert variant="danger" title="Could not save">
      Check your internet connection and try again.
    </Alert>
    <script setup lang="ts">
    import Alert from "@/components/markas/Alert.vue";
    </script>
    
    <template>
      <Alert title="Update available" role="status">
        Version 2.1 can be installed at any time.
      </Alert>
      <Alert variant="danger" title="Could not save">
        Check your internet connection and try again.
      </Alert>
    </template>
    <script lang="ts">
      import Alert from "$lib/components/markas/Alert.svelte";
    </script>
    
    <Alert title="Update available" role="status">
      Version 2.1 can be installed at any time.
    </Alert>
    <Alert variant="danger" title="Could not save">
      Check your internet connection and try again.
    </Alert>
    ---
    import Alert from "@/components/markas/Alert.astro";
    ---
    
    <Alert title="Update available" role="status">
      Version 2.1 can be installed at any time.
    </Alert>
    <Alert variant="danger" title="Could not save">
      Check your internet connection and try again.
    </Alert>
    import { Component } from "@angular/core";
    import { Alert } from "./markas/alert.component";
    
    @Component({
      selector: "app-status",
      imports: [Alert],
      template: `
        <markas-alert title="Update available" role="status">
          Version 2.1 can be installed at any time.
        </markas-alert>
        <markas-alert variant="danger" title="Could not save">
          Check your internet connection and try again.
        </markas-alert>
      `,
    })
    export class Status {}
    • The default role="alert" is announced by screen readers right away. For non-urgent information, set role="status".
    • No JavaScript, so the Blade version does not need Alpine.js.

    Props

    NameTypeDefaultDescription
    variant'info' | 'success' | 'warning' | 'danger'infoBackground, border, and icon color.
    titlestring-Bold heading above the body. Pass the body through the slot or children.
    role'alert' | 'status'alertNative role attribute. Use status for non-urgent information so screen readers do not interrupt.

    Accessibility

    • Defaults to role alert, so screen readers announce an alert that appears after page load right away.
    • Set role status for non-urgent information.
    • The icon is decorative (aria-hidden). Meaning is carried by the title and text.
    • Title and body use the ink color, so contrast meets AA in light and dark mode.

    Related components

    More feedback components with the same classes in every framework.