Components · Feedback
Alert
An inline, contextual feedback banner — info, success, warning, error, or branding — in regular/small sizes, with an optional full-width banner mode and a trailing action.
Examples
Type
Size
Banner
Icon
Types · info · success · warning · error · branding · small · banner · action
<!-- Paste-and-run: save as .html and open in a browser. No build step.
<aha-alert> is the SAME shared custom element React and Vue consume — here in its
native form. Importing it also registers <aha-icon> for the status glyph. Theming
comes only from the --aha-* tokens in tokens.css. -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/ahaslides-product/ahaslides-design@master/lib/tokens.css">
<script type="module">
import 'https://cdn.jsdelivr.net/gh/ahaslides-product/ahaslides-design@master/lib/aha-alert.js'; // registers <aha-alert> (+ <aha-icon>)
</script>
<div style="display:flex; flex-direction:column; gap:12px; max-width:520px">
<aha-alert type="info" heading="Heads up">Your poll closes in 5 minutes.</aha-alert>
<aha-alert type="success" size="small">Slide saved.</aha-alert>
<aha-alert type="warning" heading="Almost at the limit">You have used 9 of 10 slides on the Free plan.</aha-alert>
<aha-alert type="error" closable id="err">Upload failed — the file is over 20 MB.</aha-alert>
<aha-alert type="branding" heading="New: AI slide generation">
Turn a prompt into a full deck.
<button slot="action">Try it</button>
</aha-alert>
</div>
<!-- banner = full-width, square-cornered page notice (drop it at the top of the layout) -->
<aha-alert type="warning" banner closable>Scheduled maintenance tonight 22:00–23:00 UTC.</aha-alert>
<script>
document.getElementById('err').addEventListener('close', () => console.log('alert dismissed'));
</script>
import '@ahaslides-product/design/aha-alert'; // registers <aha-alert> (+ <aha-icon>)
import { useRef, useEffect } from 'react';
// React 18 needs a thin wrapper for the composed `close` event; React 19 can bind onClose directly.
function AhaAlert({ type, heading, size, banner, hideIcon, closable, onClose, action, children }) {
const ref = useRef();
useEffect(() => {
const el = ref.current;
const h = () => onClose?.();
el.addEventListener('close', h);
return () => el.removeEventListener('close', h);
});
return (
<aha-alert
ref={ref}
type={type}
{...(heading ? { heading } : {})}
{...(size ? { size } : {})}
{...(banner ? { banner: '' } : {})}
{...(hideIcon ? { 'hide-icon': '' } : {})}
{...(closable ? { closable: '' } : {})}
>
{children}
{action ? <span slot="action">{action}</span> : null}
</aha-alert>
);
}
// usage
<AhaAlert type="success" heading="Saved">Your changes are live.</AhaAlert>
<AhaAlert type="branding" heading="New: AI slides" action={<button>Try it</button>}>Turn a prompt into a deck.</AhaAlert>
<AhaAlert type="warning" banner closable onClose={() => setBanner(null)}>Scheduled maintenance tonight.</AhaAlert>
<AhaAlert type="error" size="small" closable onClose={() => setBanner(null)}>Upload failed — try a smaller file.</AhaAlert>
// main.ts — register the element + mark aha-* as custom elements
import '@ahaslides-product/design/aha-alert'; // registers <aha-alert> (+ <aha-icon>)
app.config.compilerOptions.isCustomElement = (tag) => tag.startsWith('aha-');
// Component.vue
<script setup>
import { ref } from 'vue';
const banner = ref(true);
</script>
<template>
<aha-alert type="success" heading="Saved">Your changes are live.</aha-alert>
<aha-alert type="branding" heading="New: AI slides">
Turn a prompt into a deck.
<button slot="action">Try it</button>
</aha-alert>
<aha-alert type="error" size="small">Upload failed — try a smaller file.</aha-alert>
<aha-alert
v-if="banner"
type="warning"
banner
closable
@close="banner = false"
>
Scheduled maintenance tonight 22:00–23:00 UTC.
</aha-alert>
</template>
API
| Prop | Type | Default | Notes |
|---|---|---|---|
type | info | success | warning | error | branding | info | Tone + status icon + surface/border tokens |
heading | string | — | Optional bold title above the message |
size | regular | small | regular | Compact padding + type scale |
banner | boolean | false | Full-width, square-cornered edge-to-edge page notice |
closable | boolean | false | Shows a dismiss control (✕ chrome) |
hide-icon | boolean | false | Suppresses the leading status icon (the showIcon toggle) |
slot="action" | slot | — | Trailing action — a button or link |
close | CustomEvent | — | Composed event when the banner is dismissed |
Install
# .npmrc — once: point the @ahaslides-product scope at GitHub Packages
@ahaslides-product:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} # a GitHub token with read:packages
npm i @ahaslides-product/design
import '@ahaslides-product/design/tokens.css'; // once, at the app root
import '@ahaslides-product/design/aha-alert'; // registers <aha-alert>
Agent feed for this component (absolute, fetchable anywhere): alert.agent.json · alert.md · alert.llms.txt
When to use
When to use
- Alert — a persistent, inline message tied to a region of the page (a form warning, a page-level notice)
- Toast — a brief, transient confirmation of an action that then disappears
- Notification — a richer, stacking message with a title + description, often from a background event
Keep the message to one or two lines; lead with what happened, then what to do. Reserve error for real failures — over-using red trains people to ignore it.
Surfaces
editor dashboard settings audience
Spec
Box flex row, gap 10 · padding 10 14 · radius 8 · 1px tonal border · Text Plus Jakarta 14/1.5; heading SemiBold 600 · Info bg #F4F8FF, border #BFD2FF, icon #9BB3E9 · Success bg #D8FAEF, border #16C49A, icon/text #13A181 · Warning bg #FFF5F0, border #FF7747, icon/text #E65B29 · Error bg #FFF1F0, border #F5222D, icon/text #F5222D · Branding bg-accent #F9F5FF, border-focus #D3B4FF, icon/text color-primary #6A1EBB · Small padding 6 10 · gap 8 · 13px text · 16px glyph · Banner full-width, square (radius 0), border on the bottom edge only · Action trailing slot="action" for a button/link · Icon status glyph via <aha-icon> (system-info / system-check-circle / system-warning-circle / system-x-circle / system-sparkle)