Components
Alert
Communicates a short, important message inline with the page.
Installation
$ npx veil-ui@latest add alertUsage
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
<Alert>
<AlertTitle>Heads up</AlertTitle>
<AlertDescription>Something changed.</AlertDescription>
</Alert>;Examples
Basic
Heads up
This project is on the free plan. Deployments older than 30 days are removed automatically.
Destructive
Deployment failed
The build exited with code 1. Check the logs for details.
With icon
New in v0.1
Registry, CLI and 42 core components are rolling out.
With action
Install the CLI
npx veil-ui@latest initAPI reference
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "destructive" | "default" | Visual style of the alert. |
| ...props | React.ComponentProps<"div"> | — | All native div attributes. |
Accessibility
- The root uses
role="alert", so it is announced when inserted into the DOM. Static alerts rendered on page load can be wrapped in adivwithout the role if the announcement would be noisy. - Do not convey status through color alone; keep an icon or a text label.
- Actions inside the alert should be reachable by keyboard in reading order.
Vue and plain HTML
This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add alert --framework vue or switch the framework in components.json.
<script setup lang="ts">
import { computed } from "vue";
import { cn } from "@/lib/utils";
import { alertVariants, type AlertVariants } from "./variants";
const props = defineProps<{
class?: string;
variant?: AlertVariants["variant"];
}>();
const classes = computed(() =>
cn(alertVariants({ variant: props.variant }), props.class),
);
</script>
<template>
<div
data-slot="alert"
:data-variant="variant ?? 'default'"
role="alert"
:class="classes"
>
<slot />
</div>
</template>