Issue 01 · Feedback · p.45
Alerts
Info, success, warning and error banners. Each pairs color with an icon and text, so meaning never relies on color alone.
Why it works: Use role="status" for polite updates and role="alert" only for urgent errors; alert interrupts screen readers.
Try it:
Receipt: axe clean · contrast 5.81:1 · 0 tab stops · RTL ✓ · long text ✓
- PASS axe, WCAG 2.1 A and AA: no violations in light or dark (10 rules passed).
- PASS Tightest text contrast 5.81:1, where 4.5:1 is needed (dark).
- PASS Still passes contrast with tokens fitted to a yellow brand colour.
- PASS Right-to-left with Arabic sample text fits a 390px phone.
- PASS Every string 40% longer still fits a 390px phone.
- PASS No motion.
Tab order: nothing here takes focus (it is content, not controls).
What assistive tech is given
- status: - paragraph: New version available - paragraph: Refresh the page to get the latest features. - status: - paragraph: Payment received - paragraph: A receipt is on its way to your inbox. - status: - paragraph: Storage almost full - paragraph: You’ve used 92% of your plan. Free up space or upgrade. - alert: - paragraph: Couldn’t save your changes - paragraph: Check your connection and try again.
Automated checks in CI (axe in Chromium, reduced motion on). They catch a lot, not everything: still try it with a screen reader.
See it in the zine npx -y tearsheet add alerts
Needs the shared tokens.css once per project.
HTML + CSS
index.html
<!-- tearsheet alerts v6df2fcfc · https://qusaialjbali.github.io/tearsheet/zine/parts/alerts.html -->
<div class="alerts">
<div class="alert alert-info" role="status">
<svg class="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M10 9v5M10 6v.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
<div>
<p class="alert-title">New version available</p>
<p class="alert-text">Refresh the page to get the latest features.</p>
</div>
</div>
<div class="alert alert-success" role="status">
<svg class="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="m6.5 10.2 2.3 2.3 4.7-4.9" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>
<div>
<p class="alert-title">Payment received</p>
<p class="alert-text">A receipt is on its way to your inbox.</p>
</div>
</div>
<div class="alert alert-warning" role="status">
<svg class="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M10 2.8 18 17H2Z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M10 8v4M10 14.5v.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
<div>
<p class="alert-title">Storage almost full</p>
<p class="alert-text">You’ve used 92% of your plan. Free up space or upgrade.</p>
</div>
</div>
<div class="alert alert-error" role="alert">
<svg class="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="m7.2 7.2 5.6 5.6M12.8 7.2l-5.6 5.6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
<div>
<p class="alert-title">Couldn’t save your changes</p>
<p class="alert-text">Check your connection and try again.</p>
</div>
</div>
</div>styles.css
/* tearsheet alerts v6df2fcfc · https://qusaialjbali.github.io/tearsheet/zine/parts/alerts.html */
.alerts { display: grid; gap: 12px; width: 100%; max-width: 520px; }
.alert {
--tone: var(--ui-accent);
--tone-soft: var(--ui-accent-soft);
display: flex;
gap: 12px;
align-items: flex-start;
padding: 14px 16px;
border-radius: var(--ui-radius-sm);
background: var(--tone-soft);
border: 1px solid color-mix(in srgb, var(--tone) 30%, transparent);
border-left: 4px solid var(--tone);
}
.alert-success { --tone: var(--ui-success); --tone-soft: var(--ui-success-soft); }
.alert-warning { --tone: var(--ui-warning); --tone-soft: var(--ui-warning-soft); }
.alert-error { --tone: var(--ui-danger); --tone-soft: var(--ui-danger-soft); }
.alert-icon { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--tone); }
.alert-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ui-text); }
.alert-text { margin: 2px 0 0; font-size: 14px; color: var(--ui-muted); }React
Alerts.jsx
/* tearsheet alerts v6df2fcfc · https://qusaialjbali.github.io/tearsheet/zine/parts/alerts.html */
import './Alerts.css';
export function Alerts() {
return (
<div className="alerts">
<div className="alert alert-info" role="status">
<svg className="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" strokeWidth="1.8"/><path d="M10 9v5M10 6v.5" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round"/></svg>
<div>
<p className="alert-title">New version available</p>
<p className="alert-text">Refresh the page to get the latest features.</p>
</div>
</div>
<div className="alert alert-success" role="status">
<svg className="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" strokeWidth="1.8"/><path d="m6.5 10.2 2.3 2.3 4.7-4.9" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>
<div>
<p className="alert-title">Payment received</p>
<p className="alert-text">A receipt is on its way to your inbox.</p>
</div>
</div>
<div className="alert alert-warning" role="status">
<svg className="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M10 2.8 18 17H2Z" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinejoin="round"/><path d="M10 8v4M10 14.5v.5" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round"/></svg>
<div>
<p className="alert-title">Storage almost full</p>
<p className="alert-text">You’ve used 92% of your plan. Free up space or upgrade.</p>
</div>
</div>
<div className="alert alert-error" role="alert">
<svg className="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" strokeWidth="1.8"/><path d="m7.2 7.2 5.6 5.6M12.8 7.2l-5.6 5.6" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round"/></svg>
<div>
<p className="alert-title">Couldn’t save your changes</p>
<p className="alert-text">Check your connection and try again.</p>
</div>
</div>
</div>
);
}Alerts.css
/* tearsheet alerts v6df2fcfc · https://qusaialjbali.github.io/tearsheet/zine/parts/alerts.html */
.alerts { display: grid; gap: 12px; width: 100%; max-width: 520px; }
.alert {
--tone: var(--ui-accent);
--tone-soft: var(--ui-accent-soft);
display: flex;
gap: 12px;
align-items: flex-start;
padding: 14px 16px;
border-radius: var(--ui-radius-sm);
background: var(--tone-soft);
border: 1px solid color-mix(in srgb, var(--tone) 30%, transparent);
border-left: 4px solid var(--tone);
}
.alert-success { --tone: var(--ui-success); --tone-soft: var(--ui-success-soft); }
.alert-warning { --tone: var(--ui-warning); --tone-soft: var(--ui-warning-soft); }
.alert-error { --tone: var(--ui-danger); --tone-soft: var(--ui-danger-soft); }
.alert-icon { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--tone); }
.alert-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ui-text); }
.alert-text { margin: 2px 0 0; font-size: 14px; color: var(--ui-muted); }Vue
Alerts.vue
<!-- tearsheet alerts v6df2fcfc · https://qusaialjbali.github.io/tearsheet/zine/parts/alerts.html -->
<template>
<div class="alerts">
<div class="alert alert-info" role="status">
<svg class="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M10 9v5M10 6v.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
<div>
<p class="alert-title">New version available</p>
<p class="alert-text">Refresh the page to get the latest features.</p>
</div>
</div>
<div class="alert alert-success" role="status">
<svg class="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="m6.5 10.2 2.3 2.3 4.7-4.9" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>
<div>
<p class="alert-title">Payment received</p>
<p class="alert-text">A receipt is on its way to your inbox.</p>
</div>
</div>
<div class="alert alert-warning" role="status">
<svg class="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M10 2.8 18 17H2Z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M10 8v4M10 14.5v.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
<div>
<p class="alert-title">Storage almost full</p>
<p class="alert-text">You’ve used 92% of your plan. Free up space or upgrade.</p>
</div>
</div>
<div class="alert alert-error" role="alert">
<svg class="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="m7.2 7.2 5.6 5.6M12.8 7.2l-5.6 5.6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
<div>
<p class="alert-title">Couldn’t save your changes</p>
<p class="alert-text">Check your connection and try again.</p>
</div>
</div>
</div>
</template>
<style scoped>
.alerts { display: grid; gap: 12px; width: 100%; max-width: 520px; }
.alert {
--tone: var(--ui-accent);
--tone-soft: var(--ui-accent-soft);
display: flex;
gap: 12px;
align-items: flex-start;
padding: 14px 16px;
border-radius: var(--ui-radius-sm);
background: var(--tone-soft);
border: 1px solid color-mix(in srgb, var(--tone) 30%, transparent);
border-left: 4px solid var(--tone);
}
.alert-success { --tone: var(--ui-success); --tone-soft: var(--ui-success-soft); }
.alert-warning { --tone: var(--ui-warning); --tone-soft: var(--ui-warning-soft); }
.alert-error { --tone: var(--ui-danger); --tone-soft: var(--ui-danger-soft); }
.alert-icon { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--tone); }
.alert-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ui-text); }
.alert-text { margin: 2px 0 0; font-size: 14px; color: var(--ui-muted); }
</style>Svelte
Alerts.svelte
<!-- tearsheet alerts v6df2fcfc · https://qusaialjbali.github.io/tearsheet/zine/parts/alerts.html -->
<div class="alerts">
<div class="alert alert-info" role="status">
<svg class="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M10 9v5M10 6v.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
<div>
<p class="alert-title">New version available</p>
<p class="alert-text">Refresh the page to get the latest features.</p>
</div>
</div>
<div class="alert alert-success" role="status">
<svg class="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="m6.5 10.2 2.3 2.3 4.7-4.9" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>
<div>
<p class="alert-title">Payment received</p>
<p class="alert-text">A receipt is on its way to your inbox.</p>
</div>
</div>
<div class="alert alert-warning" role="status">
<svg class="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M10 2.8 18 17H2Z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M10 8v4M10 14.5v.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
<div>
<p class="alert-title">Storage almost full</p>
<p class="alert-text">You’ve used 92% of your plan. Free up space or upgrade.</p>
</div>
</div>
<div class="alert alert-error" role="alert">
<svg class="alert-icon" viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="m7.2 7.2 5.6 5.6M12.8 7.2l-5.6 5.6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
<div>
<p class="alert-title">Couldn’t save your changes</p>
<p class="alert-text">Check your connection and try again.</p>
</div>
</div>
</div>
<style>
.alerts { display: grid; gap: 12px; width: 100%; max-width: 520px; }
.alert {
--tone: var(--ui-accent);
--tone-soft: var(--ui-accent-soft);
display: flex;
gap: 12px;
align-items: flex-start;
padding: 14px 16px;
border-radius: var(--ui-radius-sm);
background: var(--tone-soft);
border: 1px solid color-mix(in srgb, var(--tone) 30%, transparent);
border-left: 4px solid var(--tone);
}
.alert-success { --tone: var(--ui-success); --tone-soft: var(--ui-success-soft); }
.alert-warning { --tone: var(--ui-warning); --tone-soft: var(--ui-warning-soft); }
.alert-error { --tone: var(--ui-danger); --tone-soft: var(--ui-danger-soft); }
.alert-icon { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--tone); }
.alert-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ui-text); }
.alert-text { margin: 2px 0 0; font-size: 14px; color: var(--ui-muted); }
</style>