Veil UI
Components

Notification

A single notification entry with icon, copy, timestamp and dismissal.

Installation

$ npx veil-ui@latest add notification

Usage

import { Bell } from "lucide-react";
import { Notification } from "@/components/ui/notification";

<Notification
  title="Deployment finished"
  description="Production is running commit 4f2a91c."
  timestamp="2 minutes ago"
  icon={Bell}
  unread
/>;

Examples

Basic

Deployment finished

Production is running commit 4f2a91c.

2 minutes ago

Unread

New comment on your review

Unread

Ada left feedback on the spacing tokens.

10 minutes ago

Dismissible

Usage report is ready

Your monthly report can be downloaded.

Yesterday

With action

New team invitation

Unread

You were invited to the Design Systems workspace.

5 minutes ago

API reference

PropTypeDefaultDescription
titleReact.ReactNode—Headline of the notification.
descriptionReact.ReactNode—Supporting body copy.
iconReact.ElementType—Leading decorative icon.
timestampReact.ReactNode—Relative or absolute time.
unreadbooleanfalseHighlights the entry and adds a hidden “Unread” label.
onDismiss() => void—Shows a dismiss control when provided.
actionReact.ReactNode—Inline controls such as Accept / Decline.

Accessibility

  • Unread entries expose a screen-reader-only “Unread” label rather than relying on the dot alone.
  • The dismiss button defaults to “Dismiss notification” and accepts a dismissLabel override.
  • Timestamps are plain text; include a machine-readable <time> element in timestamp when exact dates matter.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add notification --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { X } from "lucide-vue-next";
import { computed, getCurrentInstance } from "vue";

import { cn } from "@/lib/utils";

import type { NotificationProps } from "./types";

const props = withDefaults(defineProps<NotificationProps>(), {
  unread: false,
  dismissible: false,
  dismissLabel: "Dismiss notification",
});

const emit = defineEmits<{ dismiss: [] }>();

const instance = getCurrentInstance();
const hasDismissListener = computed(() =>
  Boolean(instance?.vnode.props?.onDismiss),
);
const showDismiss = computed(
  () => props.dismissible || hasDismissListener.value,
);
</script>

<template>
  <div
    data-slot="notification"
    :data-unread="unread || undefined"
    :class="
      cn(
        'relative flex w-full items-start gap-3 rounded-lg border bg-card p-3 text-sm shadow-xs',
        unread && 'border-primary/30 bg-primary/5',
        props.class,
      )
    "
  >
    <div
      v-if="icon || $slots.icon"
      aria-hidden
      class="mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground"
    >
      <slot name="icon">
        <component :is="icon" class="size-4" />
      </slot>
    </div>
    <div class="grid min-w-0 flex-1 gap-0.5">
      <div class="flex items-center gap-2">
        <p class="truncate font-medium">
          <slot name="title">{{ title }}</slot>
        </p>
        <span v-if="unread" class="sr-only">Unread</span>
      </div>
      <p v-if="description || $slots.description" class="text-muted-foreground">
        <slot name="description">{{ description }}</slot>
      </p>
      <span
        v-if="timestamp || $slots.timestamp"
        class="text-xs text-muted-foreground"
      >
        <slot name="timestamp">{{ timestamp }}</slot>
      </span>
      <div v-if="$slots.action" class="mt-2">
        <slot name="action" />
      </div>
    </div>
    <button
      v-if="showDismiss"
      type="button"
      :aria-label="dismissLabel"
      class="-mt-1 -mr-1 inline-flex size-8 shrink-0 items-center justify-center rounded-md outline-none transition-[color,background-color,border-color,box-shadow] hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
      @click="emit('dismiss')"
    >
      <X />
    </button>
    <span
      v-if="unread"
      aria-hidden
      class="absolute top-3 right-3 size-1.5 rounded-full bg-primary"
    />
  </div>
</template>

On this page