Alerts 1.2.2
Provide contextual feedback with the .velin-alert component. Alerts support four
semantic variants, optional icons, titles, and a dismissible close button. Deutsch: Hinweise
Maturity: Documented as stable in VelinStyle 1.2.0. Design Intelligence (plan / review / agent meta) is separate and beta / foundation where noted.
When to use
- Persistent, in-flow status next to the content it describes (form banners, page notices, inline warnings).
- When the message should remain visible until the user dismisses it or navigates away.
When not
- Transient, non-blocking feedback after an action — use Toasts.
- Blocking confirmations — use Dialog or Modal.
- There is no
<velin-alert>web component; use the CSS pattern on this page.
Basic Example
This is an informational alert.
Action completed successfully!
Please check your input.
Something went wrong.
<div class="velin-alert velin-alert--info" role="alert">
<div class="velin-alert__content">This is an informational alert.</div>
</div>
<div class="velin-alert velin-alert--success" role="alert">
<div class="velin-alert__content">Action completed successfully!</div>
</div>
<div class="velin-alert velin-alert--warning" role="alert">
<div class="velin-alert__content">Please check your input.</div>
</div>
<div class="velin-alert velin-alert--danger" role="alert">
<div class="velin-alert__content">Something went wrong.</div>
</div>
With Icon & Title
Heads up!
This alert has an icon and a bold title for emphasis.
<div class="velin-alert velin-alert--info" role="alert">
<velin-icon name="info" size="20" class="velin-alert__icon"></velin-icon>
<div class="velin-alert__content">
<div class="velin-alert__title">Heads up!</div>
This alert has an icon and a bold title for emphasis.
</div>
</div>
Dismissible
Add a .velin-alert__close button. A small script removes the alert on click.
You can dismiss me!
<div class="velin-alert velin-alert--warning" role="alert">
<div class="velin-alert__content">You can dismiss me!</div>
<button class="velin-alert__close" aria-label="Close"
onclick="this.closest('.velin-alert').remove()">×</button>
</div>
Accessibility
- Use
role="alert"for urgent messages that must interrupt; userole="status"for quieter, polite announcements. - Dismiss controls need an accessible name (e.g.
aria-label="Close"). - Do not rely on colour alone — pair variants with icons or clear titles for colour-blind users.
- Keep important instructions in the document flow; alerts are not a substitute for field-level errors (see Form summary).
CSS Variables / classes
| Variable | Description |
|---|---|
--velin-color-info-subtle | Background for .velin-alert--info |
--velin-color-info | Border for .velin-alert--info |
--velin-color-success-subtle | Background for .velin-alert--success |
--velin-color-success | Border for .velin-alert--success |
--velin-color-warning-subtle | Background for .velin-alert--warning |
--velin-color-warning | Border for .velin-alert--warning |
--velin-color-danger-subtle | Background for .velin-alert--danger |
--velin-color-danger | Border for .velin-alert--danger |
--velin-radius-md | Border radius |
--velin-space-3 | Gap between icon and content |
--velin-space-4 | Padding |
Variants: .velin-alert--info, --success, --warning, --danger. Structure: .velin-alert__icon, __content, __title, __close.
Best practices & pitfalls
- Prefer short, actionable copy; link to the next step when recovery is needed.
- Dismissible alerts need a small script (or framework handler) — CSS alone does not remove the node.
- Do not invent Bootstrap
.alert-*class names; stick to.velin-alert--*.
Related
- Toasts — stacked, transient notifications
- Form summary — submit-time error list
- Announcer — live region utility