सुलभता पैटर्न · फ़ीडबैक और स्थिति
अलर्ट बैनर
पेज पर पहले से मौजूद अलर्ट सादी सामग्री हैं: टोन बताने वाला एक शब्द, एक आइकन और एक हेडिंग, जो बाक़ी पेज की तरह क्रम से पढ़े जाते हैं। सिर्फ़ बाद में होने वाली त्रुटि, जैसे विफल भुगतान, उस role=alert कंटेनर में जाती है जो शुरू से पेज में था, इसलिए उसकी घोषणा तुरंत होती है और फ़ोकस अपनी जगह रहता है।
- डब्ल्यूसीएजी मानदंड
- 6
- कीबोर्ड नियम
- 3
- जाँच का तरीक़ा
- axe, कीबोर्ड और इंस्पेक्टर
लाइव डेमो
आज़माएँ
इसे माउस, कीबोर्ड या स्क्रीन रीडर से इस्तेमाल करें। साथ का इंस्पेक्टर दिखाता है कि आपके इस्तेमाल के दौरान ब्राउज़र सहायक तकनीक को क्या बताता है: फ़ोकस, स्थिति में बदलाव और घोषणाएँ।
बिलिंग
स्टूडियो प्लान, सालाना भुगतान
जानकारी: निर्धारित रखरखाव
रविवार 12 अक्टूबर को सुबह 2 से 4 बजे (IST) तक कार्ड भुगतान रुके रहेंगे। UPI चलता रहेगा।
सेवा की स्थिति देखेंसफलता: कार्ड जोड़ा गया
4418 पर ख़त्म होने वाला आपका HDFC बैंक कार्ड अब इस प्लान का भुगतान करता है।
चेतावनी: आपका प्लान 3 दिन में रिन्यू होगा
8 अक्टूबर को ₹4,999 लिए जाएँगे। ज़रूरत हो तो उससे पहले प्लान बदलें या रद्द करें।
अपना प्लान देखेंत्रुटि: GST नंबर सत्यापित नहीं हुआ
दर्ज GSTIN आपके व्यवसाय के नाम से मेल नहीं खाता, इसलिए वह आपके इनवॉइस पर नहीं दिख सकता।
GST विवरण ठीक करेंदेय राशि
₹4,999
इस डेमो में भुगतान हमेशा विफल होता है, ताकि आप अलर्ट देख सकें।
Error: Payment failed
Your bank declined the card ending 4418, and you have not been charged. Try another card, or pay by UPI.
जावास्क्रिप्ट के बिना डेमो उतना ही काम करता है जितना उसका एचटीएमएल; इंस्पेक्टर के लिए जावास्क्रिप्ट चाहिए।
कीबोर्ड
जिन कुंजियों पर यह काम करता है
हर क्रिया पॉइंटर के बिना काम करती है।
| कुंजी | यह क्या करती है |
|---|---|
| TabयाShiftTab | अलर्ट के अंदर के लिंक और बटनों से होकर जाता है; अलर्ट ख़ुद टैब क्रम में नहीं आते। |
| EnterयाSpace | ₹4,999 चुकाएँ पर, भुगतान की कोशिश करता है। त्रुटि नीचे दिखती है और उसकी घोषणा तुरंत होती है, जबकि फ़ोकस बटन पर ही रहता है। |
| EnterयाSpace | खारिज बटन पर, रखरखाव की सूचना हटाता है और फ़ोकस उस अलर्ट पर ले जाता है जो उसकी जगह लेता है। |
स्क्रीन रीडर
यह क्या घोषित करता है
मार्कअप की भूमिकाओं, नामों और स्थितियों से लिखा गया।
| कब | अपेक्षित घोषणा |
|---|---|
| पेज लोड होता है | कुछ नहीं: पेज पर पहले से मौजूद अलर्ट क्रम से पढ़े जाते हैं, कभी घोषित नहीं होते |
| पढ़ते हुए चेतावनी आती है | चेतावनी: आपका प्लान 3 दिन में रिन्यू होगा, हेडिंग स्तर 4 |
| ₹4,999 का भुगतान विफल होता है | त्रुटि: भुगतान विफल। आपके बैंक ने 4418 पर ख़त्म होने वाला कार्ड अस्वीकार कर दिया… (तुरंत, बीच में रोककर) |
| फ़ोकस खारिज बटन पर पहुँचता है | निर्धारित रखरखाव खारिज करें, बटन |
| सूचना खारिज की जाती है | सफलता: कार्ड जोड़ा गया, समूह (फ़ोकस अगले अलर्ट पर है) |
ये अपेक्षित घोषणाएँ हैं, रिकॉर्डिंग नहीं। स्क्रीन रीडर और ब्राउज़र के हिसाब से शब्द और क्रम बदलते हैं।
कोड
कोड कॉपी करें
वही फ़ाइलें जिन पर यह डेमो चलता है। स्टाइल एक प्रीफ़िक्स के साथ परोसी जाती हैं जो इस साइट की अपनी स्टाइल को डेमो से दूर रखता है; आप जो कॉपी करते हैं वह मूल है।
<div class="ap-alert" data-ap-alert>
<div class="ap-alert__top">
<h3 class="ap-alert__intro" id="alert-billing" tabindex="-1">Billing</h3>
<p class="ap-alert__lead">Studio plan, paid yearly</p>
</div>
<div class="ap-alert__stack">
<div class="ap-alert__item ap-alert__item--info" role="group" aria-labelledby="alert-info-h">
<span class="ap-alert__mark" aria-hidden="true"><svg class="ap-alert__icon" viewBox="0 0 24 24" focusable="false"><circle cx="12" cy="12" r="9"/><path d="M12 11v5"/><path d="M12 7.5h.01"/></svg></span>
<div class="ap-alert__body">
<h4 class="ap-alert__name" id="alert-info-h"><span class="ap-alert__tone">Info:</span> <span id="alert-info-name">Scheduled maintenance</span></h4>
<p class="ap-alert__text">Card payments pause on Sunday 12 October, from 2 to 4 a.m. IST. UPI keeps working.</p>
<a class="ap-alert__link" href="#alert-status">See service status</a>
</div>
<button type="button" class="ap-alert__dismiss" id="alert-info-x" aria-labelledby="alert-info-x alert-info-name" data-ap-dismiss>
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M6 6l12 12M18 6 6 18"/></svg>
<span class="ap-alert__sr">Dismiss</span>
</button>
</div>
<div class="ap-alert__item ap-alert__item--success" role="group" aria-labelledby="alert-success-h">
<span class="ap-alert__mark" aria-hidden="true"><svg class="ap-alert__icon" viewBox="0 0 24 24" focusable="false"><circle cx="12" cy="12" r="9"/><path d="m8 12.5 2.7 2.7L16.2 9.6"/></svg></span>
<div class="ap-alert__body">
<h4 class="ap-alert__name" id="alert-success-h"><span class="ap-alert__tone">Success:</span> <span>Card added</span></h4>
<p class="ap-alert__text">Your HDFC Bank card ending 4418 now pays for this plan.</p>
</div>
</div>
<div class="ap-alert__item ap-alert__item--warning" role="group" aria-labelledby="alert-warning-h">
<span class="ap-alert__mark" aria-hidden="true"><svg class="ap-alert__icon" viewBox="0 0 24 24" focusable="false"><path d="M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg></span>
<div class="ap-alert__body">
<h4 class="ap-alert__name" id="alert-warning-h"><span class="ap-alert__tone">Warning:</span> <span>Your plan renews in 3 days</span></h4>
<p class="ap-alert__text">₹4,999 will be charged on 8 October. Change or cancel the plan before then if you need to.</p>
<a class="ap-alert__link" href="#alert-plan">Review your plan</a>
</div>
</div>
<div class="ap-alert__item ap-alert__item--error" role="group" aria-labelledby="alert-error-h">
<span class="ap-alert__mark" aria-hidden="true"><svg class="ap-alert__icon" viewBox="0 0 24 24" focusable="false"><path d="M7.9 2.5h8.2l5.4 5.4v8.2l-5.4 5.4H7.9l-5.4-5.4V7.9Z"/><path d="m15 9-6 6M9 9l6 6"/></svg></span>
<div class="ap-alert__body">
<h4 class="ap-alert__name" id="alert-error-h"><span class="ap-alert__tone">Error:</span> <span>GST number not verified</span></h4>
<p class="ap-alert__text">The GSTIN on file does not match your business name, so it cannot appear on your invoices.</p>
<a class="ap-alert__link" href="#alert-gst">Fix GST details</a>
</div>
</div>
</div>
<div class="ap-alert__pay">
<div class="ap-alert__due">
<p class="ap-alert__k">Amount due</p>
<p class="ap-alert__amount">₹4,999</p>
<p class="ap-alert__hint">In this demo the payment always fails, so you can see the alert.</p>
</div>
<button type="button" class="ap-btn ap-btn--primary" data-ap-pay>Pay ₹4,999</button>
</div>
<div class="ap-alert__live" role="alert" data-ap-live></div>
<template data-ap-failed>
<div class="ap-alert__item ap-alert__item--error">
<span class="ap-alert__mark" aria-hidden="true"><svg class="ap-alert__icon" viewBox="0 0 24 24" focusable="false"><path d="M7.9 2.5h8.2l5.4 5.4v8.2l-5.4 5.4H7.9l-5.4-5.4V7.9Z"/><path d="m15 9-6 6M9 9l6 6"/></svg></span>
<div class="ap-alert__body">
<h4 class="ap-alert__name"><span class="ap-alert__tone">Error:</span> <span>Payment failed</span></h4>
<p class="ap-alert__text">Your bank declined the card ending 4418, and you have not been charged. Try another card, or pay by UPI.</p>
</div>
</div>
</template>
</div>
/* Shared primitives: buttons and form fields used across the patterns.
Uses the --ap-* design tokens. */
.ap-btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
min-height: 40px;
padding: 0 16px;
border: 1px solid var(--ap-border-strong);
border-radius: var(--ap-radius-sm);
background: var(--ap-surface);
color: var(--ap-text);
font: inherit;
font-weight: 600;
line-height: 1.2;
text-decoration: none;
white-space: nowrap;
cursor: pointer;
transition: background-color var(--ap-duration) var(--ap-ease), border-color var(--ap-duration) var(--ap-ease), box-shadow var(--ap-duration) var(--ap-ease);
}
.ap-btn:hover {
background: var(--ap-surface-2);
}
.ap-btn:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 2px;
}
.ap-btn:disabled,
.ap-btn[aria-disabled="true"] {
opacity: .55;
cursor: not-allowed;
}
.ap-btn--primary {
border-color: var(--ap-accent);
background: var(--ap-accent);
color: var(--ap-on-accent);
box-shadow: var(--ap-shadow-sm);
}
.ap-btn--primary:hover {
border-color: var(--ap-accent-hover);
background: var(--ap-accent-hover);
}
.ap-btn--danger {
border-color: var(--ap-danger);
background: var(--ap-danger);
color: var(--ap-surface);
}
.ap-btn--danger:hover {
filter: brightness(1.08);
}
.ap-btn--ghost {
border-color: transparent;
background: transparent;
}
.ap-btn--ghost:hover {
background: var(--ap-surface-2);
}
.ap-btn__icon {
width: 18px;
height: 18px;
flex-shrink: 0;
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.ap-field {
display: grid;
gap: 6px;
}
.ap-label {
color: var(--ap-text);
font-weight: 600;
font-size: .9375rem;
}
.ap-hint {
margin: 0;
color: var(--ap-text-3);
font-size: .875rem;
line-height: 1.45;
}
.ap-error {
display: flex;
align-items: flex-start;
gap: 6px;
margin: 0;
color: var(--ap-danger);
font-size: .875rem;
font-weight: 600;
line-height: 1.45;
}
.ap-input {
width: 100%;
min-height: 44px;
padding: 10px 12px;
border: 1px solid var(--ap-border-strong);
border-radius: var(--ap-radius-sm);
background: var(--ap-surface);
color: var(--ap-text);
font: inherit;
line-height: 1.4;
transition: border-color var(--ap-duration) var(--ap-ease), box-shadow var(--ap-duration) var(--ap-ease);
}
.ap-input::placeholder {
color: var(--ap-text-3);
}
.ap-input:hover {
border-color: var(--ap-text-2);
}
.ap-input:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 1px;
border-color: var(--ap-focus);
}
.ap-input[aria-invalid="true"] {
border-color: var(--ap-danger);
box-shadow: inset 4px 0 0 var(--ap-danger);
}
textarea.ap-input {
resize: vertical;
min-height: 88px;
}
@media (prefers-reduced-motion: reduce) {
.ap-btn,
.ap-input { transition: none; }
}
/* Alert banner. Uses the --ap-* design tokens and the shared primitives. */
.ap-alert {
width: min(100%, 600px);
margin-inline: auto;
padding: 24px;
border: 1px solid var(--ap-border);
border-radius: var(--ap-radius-lg);
background: var(--ap-surface);
color: var(--ap-text);
box-shadow: var(--ap-shadow-md);
container-type: inline-size;
}
.ap-alert__top {
margin-bottom: 18px;
}
.ap-alert__intro {
margin: 0;
font-size: 1.1875rem;
font-weight: 650;
line-height: 1.3;
}
/* Focus lands here only from the script, when the last alert is dismissed. */
.ap-alert__intro:focus {
outline: none;
}
.ap-alert__intro:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 4px;
border-radius: 4px;
}
.ap-alert__lead {
margin: 4px 0 0;
color: var(--ap-text-3);
line-height: 1.5;
}
.ap-alert__stack {
display: grid;
gap: 12px;
}
/* One alert. Each tone sets two colors; the word and the icon carry the
meaning, the tint repeats it. */
.ap-alert__item {
--ap-alert-tone: var(--ap-info);
--ap-alert-soft: var(--ap-info-soft);
display: grid;
grid-template-columns: auto minmax(0, 1fr) auto;
align-items: start;
column-gap: 14px;
padding: 14px 14px 16px 16px;
border: 1px solid color-mix(in srgb, var(--ap-alert-tone) 32%, transparent);
border-radius: var(--ap-radius);
background: var(--ap-alert-soft);
}
.ap-alert__item--success {
--ap-alert-tone: var(--ap-success);
--ap-alert-soft: var(--ap-success-soft);
}
.ap-alert__item--warning {
--ap-alert-tone: var(--ap-warning);
--ap-alert-soft: var(--ap-warning-soft);
}
.ap-alert__item--error {
--ap-alert-tone: var(--ap-danger);
--ap-alert-soft: var(--ap-danger-soft);
}
.ap-alert__item:focus {
outline: none;
}
.ap-alert__item:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 2px;
}
.ap-alert__mark {
display: grid;
place-items: center;
width: 34px;
height: 34px;
border-radius: var(--ap-radius-full);
background: color-mix(in srgb, var(--ap-alert-tone) 14%, transparent);
}
.ap-alert__icon {
width: 19px;
height: 19px;
fill: none;
stroke: var(--ap-alert-tone);
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.ap-alert__body {
display: grid;
gap: 3px;
min-width: 0;
padding-top: 6px;
}
.ap-alert__name {
margin: 0;
color: var(--ap-text);
font-size: 1rem;
font-weight: 650;
line-height: 1.4;
}
.ap-alert__tone {
color: var(--ap-alert-tone);
font-weight: 750;
}
.ap-alert__text {
margin: 0;
color: var(--ap-text-2);
font-size: .9375rem;
line-height: 1.55;
}
.ap-alert__link {
display: inline-flex;
align-items: center;
justify-self: start;
min-height: 24px;
margin-top: 4px;
border-radius: 4px;
color: var(--ap-alert-tone);
font-size: .9375rem;
font-weight: 600;
text-decoration: underline;
text-underline-offset: 3px;
}
.ap-alert__link:hover {
text-decoration-thickness: 2px;
}
.ap-alert__link:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 2px;
}
.ap-alert__dismiss {
display: grid;
place-items: center;
width: 32px;
height: 32px;
margin: 1px -2px 0 0;
padding: 0;
border: 0;
border-radius: var(--ap-radius-sm);
background: transparent;
color: var(--ap-text-2);
cursor: pointer;
transition: background-color var(--ap-duration) var(--ap-ease), color var(--ap-duration) var(--ap-ease);
}
.ap-alert__dismiss:hover {
background: color-mix(in srgb, var(--ap-alert-tone) 14%, transparent);
color: var(--ap-text);
}
.ap-alert__dismiss:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 1px;
}
.ap-alert__dismiss svg {
width: 18px;
height: 18px;
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
}
/* The payment, and the live region its error goes into. */
.ap-alert__pay {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 14px 20px;
margin-top: 20px;
padding: 16px 18px;
border: 1px solid var(--ap-border);
border-radius: var(--ap-radius);
background: var(--ap-surface-2);
}
.ap-alert__due {
flex: 1 1 220px;
min-width: 0;
}
.ap-alert__k {
margin: 0;
color: var(--ap-text-3);
font-size: .8125rem;
font-weight: 600;
letter-spacing: .02em;
}
.ap-alert__amount {
margin: 2px 0 0;
font-size: 1.375rem;
font-weight: 700;
line-height: 1.25;
font-variant-numeric: tabular-nums;
}
.ap-alert__hint {
margin: 6px 0 0;
color: var(--ap-text-3);
font-size: .8125rem;
line-height: 1.45;
}
.ap-alert__pay .ap-btn {
min-height: var(--ap-target);
}
/* Never display: none, even when empty: the region has to be in the
accessibility tree before the message arrives. */
.ap-alert__live:not(:empty) {
margin-top: 14px;
}
.ap-alert__live > .ap-alert__item {
animation: ap-alert-in 220ms var(--ap-ease);
}
/* Read by screen readers, not shown. */
.ap-alert__sr {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
border: 0;
}
@keyframes ap-alert-in {
from { opacity: 0; transform: translateY(-4px); }
}
/* Narrow: tighter padding, and the icon sits a little smaller. */
@container (max-width: 440px) {
.ap-alert {
padding: 20px 16px;
}
.ap-alert__item {
column-gap: 10px;
padding: 12px 10px 14px 12px;
}
.ap-alert__mark {
width: 30px;
height: 30px;
}
.ap-alert__body {
padding-top: 4px;
}
.ap-alert__pay .ap-btn {
flex: 1 1 100%;
}
}
@media (prefers-reduced-motion: reduce) {
.ap-alert__dismiss { transition: none; }
.ap-alert__live > .ap-alert__item { animation: none; }
}
/**
* Alert banner: static alerts in four tones, one of them dismissible, and a
* live alert for an error that happens while the page is in use.
*
* Markup: [data-ap-alert] holding .ap-alert__item elements inside
* .ap-alert__stack (plain content, no live role), any of which may contain a
* button[data-ap-dismiss]; a button[data-ap-pay]; an empty
* div[role=alert][data-ap-live] that is in the page from the start; and a
* template[data-ap-failed] holding the error to show. The section heading
* (.ap-alert__intro, tabindex=-1) takes focus when no alert is left.
*/
export function init(root) {
const live = root.querySelector("[data-ap-live]");
const failed = root.querySelector("template[data-ap-failed]");
let timer = 0;
// The region is already in the page, so changing what is inside it is what
// gets announced. Emptying it first and filling it a moment later makes
// the same error count as news when it happens twice.
function showError() {
clearTimeout(timer);
live.replaceChildren();
timer = setTimeout(() => {
live.append(failed.content.cloneNode(true));
}, 100);
}
function dismiss(item) {
const items = [...root.querySelectorAll(".ap-alert__stack > .ap-alert__item")];
const at = items.indexOf(item);
const next = items[at + 1] || items[at - 1] || root.querySelector(".ap-alert__intro");
item.remove();
// Focusable by script only: tabindex=-1 keeps it out of the Tab order.
if (!next.hasAttribute("tabindex")) next.tabIndex = -1;
next.focus();
}
function onClick(event) {
if (event.target.closest("[data-ap-pay]")) {
showError();
return;
}
const button = event.target.closest("[data-ap-dismiss]");
if (button && root.contains(button)) dismiss(button.closest(".ap-alert__item"));
}
root.addEventListener("click", onClick);
return () => {
clearTimeout(timer);
root.removeEventListener("click", onClick);
};
}
for (const root of document.querySelectorAll("[data-ap-alert]")) init(root);
/* Design tokens for the pattern components. Light by default, dark when the
system asks for it; set data-theme="dark" on :root to force dark. */
:root {
--ap-radius-sm: 8px;
--ap-radius: 12px;
--ap-radius-lg: 16px;
--ap-radius-full: 999px;
--ap-font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--ap-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
--ap-ease: cubic-bezier(.2, .8, .2, 1);
--ap-duration: 180ms;
--ap-target: 44px;
--ap-bg: #F4F4F5;
--ap-surface: #FFFFFF;
--ap-surface-2: #F4F4F5;
--ap-surface-3: #E4E4E7;
--ap-border: #E4E4E7;
--ap-border-strong: #76767F;
--ap-text: #18181B;
--ap-text-2: #3F3F46;
--ap-text-3: #5E5E66;
--ap-accent: #4F46E5;
--ap-accent-hover: #4338CA;
--ap-on-accent: #FFFFFF;
--ap-accent-text: #4338CA;
--ap-accent-soft: #EEF2FF;
--ap-accent-soft-text: #3730A3;
--ap-focus: #4F46E5;
--ap-danger: #B91C1C;
--ap-danger-soft: #FEF2F2;
--ap-success: #15803D;
--ap-success-soft: #F0FDF4;
--ap-warning: #A15C07;
--ap-warning-soft: #FEFCE8;
--ap-info: #1D4ED8;
--ap-info-soft: #EFF6FF;
--ap-scrim: rgb(9 9 11 / .48);
--ap-shadow-sm: 0 1px 2px rgb(9 9 11 / .06);
--ap-shadow-md: 0 1px 2px rgb(9 9 11 / .05), 0 6px 16px -4px rgb(9 9 11 / .1);
--ap-shadow-lg: 0 2px 6px rgb(9 9 11 / .06), 0 20px 40px -12px rgb(9 9 11 / .22);
--ap-light-bg: #F4F4F5;
--ap-light-surface: #FFFFFF;
--ap-light-surface-2: #F4F4F5;
--ap-light-surface-3: #E4E4E7;
--ap-light-border: #E4E4E7;
--ap-light-border-strong: #76767F;
--ap-light-text: #18181B;
--ap-light-text-2: #3F3F46;
--ap-light-text-3: #5E5E66;
--ap-light-accent: #4F46E5;
--ap-light-accent-hover: #4338CA;
--ap-light-on-accent: #FFFFFF;
--ap-light-accent-text: #4338CA;
--ap-light-accent-soft: #EEF2FF;
--ap-light-accent-soft-text: #3730A3;
--ap-light-focus: #4F46E5;
--ap-light-danger: #B91C1C;
--ap-light-danger-soft: #FEF2F2;
--ap-light-success: #15803D;
--ap-light-success-soft: #F0FDF4;
--ap-light-warning: #A15C07;
--ap-light-warning-soft: #FEFCE8;
--ap-light-info: #1D4ED8;
--ap-light-info-soft: #EFF6FF;
--ap-light-scrim: rgb(9 9 11 / .48);
--ap-light-shadow-sm: 0 1px 2px rgb(9 9 11 / .06);
--ap-light-shadow-md: 0 1px 2px rgb(9 9 11 / .05), 0 6px 16px -4px rgb(9 9 11 / .1);
--ap-light-shadow-lg: 0 2px 6px rgb(9 9 11 / .06), 0 20px 40px -12px rgb(9 9 11 / .22);
--ap-dark-bg: #09090B;
--ap-dark-surface: #18181B;
--ap-dark-surface-2: #27272A;
--ap-dark-surface-3: #3F3F46;
--ap-dark-border: #2E2E33;
--ap-dark-border-strong: #8E8E97;
--ap-dark-text: #FAFAFA;
--ap-dark-text-2: #D4D4D8;
--ap-dark-text-3: #A1A1AA;
--ap-dark-accent: #818CF8;
--ap-dark-accent-hover: #A5B4FC;
--ap-dark-on-accent: #0C0A1F;
--ap-dark-accent-text: #A5B4FC;
--ap-dark-accent-soft: #1E1B4B;
--ap-dark-accent-soft-text: #C7D2FE;
--ap-dark-focus: #A5B4FC;
--ap-dark-danger: #F87171;
--ap-dark-danger-soft: #2A1215;
--ap-dark-success: #4ADE80;
--ap-dark-success-soft: #0F2A1A;
--ap-dark-warning: #FACC15;
--ap-dark-warning-soft: #2A2410;
--ap-dark-info: #60A5FA;
--ap-dark-info-soft: #0F1D33;
--ap-dark-scrim: rgb(0 0 0 / .62);
--ap-dark-shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
--ap-dark-shadow-md: 0 1px 2px rgb(0 0 0 / .4), 0 8px 20px -6px rgb(0 0 0 / .5);
--ap-dark-shadow-lg: 0 2px 8px rgb(0 0 0 / .45), 0 24px 48px -12px rgb(0 0 0 / .7);
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--ap-bg: #09090B;
--ap-surface: #18181B;
--ap-surface-2: #27272A;
--ap-surface-3: #3F3F46;
--ap-border: #2E2E33;
--ap-border-strong: #8E8E97;
--ap-text: #FAFAFA;
--ap-text-2: #D4D4D8;
--ap-text-3: #A1A1AA;
--ap-accent: #818CF8;
--ap-accent-hover: #A5B4FC;
--ap-on-accent: #0C0A1F;
--ap-accent-text: #A5B4FC;
--ap-accent-soft: #1E1B4B;
--ap-accent-soft-text: #C7D2FE;
--ap-focus: #A5B4FC;
--ap-danger: #F87171;
--ap-danger-soft: #2A1215;
--ap-success: #4ADE80;
--ap-success-soft: #0F2A1A;
--ap-warning: #FACC15;
--ap-warning-soft: #2A2410;
--ap-info: #60A5FA;
--ap-info-soft: #0F1D33;
--ap-scrim: rgb(0 0 0 / .62);
--ap-shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
--ap-shadow-md: 0 1px 2px rgb(0 0 0 / .4), 0 8px 20px -6px rgb(0 0 0 / .5);
--ap-shadow-lg: 0 2px 8px rgb(0 0 0 / .45), 0 24px 48px -12px rgb(0 0 0 / .7);
}
}
:root[data-theme="dark"] {
--ap-bg: #09090B;
--ap-surface: #18181B;
--ap-surface-2: #27272A;
--ap-surface-3: #3F3F46;
--ap-border: #2E2E33;
--ap-border-strong: #8E8E97;
--ap-text: #FAFAFA;
--ap-text-2: #D4D4D8;
--ap-text-3: #A1A1AA;
--ap-accent: #818CF8;
--ap-accent-hover: #A5B4FC;
--ap-on-accent: #0C0A1F;
--ap-accent-text: #A5B4FC;
--ap-accent-soft: #1E1B4B;
--ap-accent-soft-text: #C7D2FE;
--ap-focus: #A5B4FC;
--ap-danger: #F87171;
--ap-danger-soft: #2A1215;
--ap-success: #4ADE80;
--ap-success-soft: #0F2A1A;
--ap-warning: #FACC15;
--ap-warning-soft: #2A2410;
--ap-info: #60A5FA;
--ap-info-soft: #0F1D33;
--ap-scrim: rgb(0 0 0 / .62);
--ap-shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
--ap-shadow-md: 0 1px 2px rgb(0 0 0 / .4), 0 8px 20px -6px rgb(0 0 0 / .5);
--ap-shadow-lg: 0 2px 8px rgb(0 0 0 / .45), 0 24px 48px -12px rgb(0 0 0 / .7);
}
डब्ल्यूसीएजी 2.2
यह किन मानदंडों को पूरा करता है
वे सफलता मानदंड जिनका यह पैटर्न ध्यान रखता है, और कैसे।
-
1.3.1 जानकारी और संबंध
स्तर A
हर अलर्ट में एक असली हेडिंग है जो उसके टोन से शुरू होती है, इसलिए अलर्ट स्क्रीन रीडर की हेडिंग सूची में अपने अर्थ के साथ दिखते हैं।
-
1.4.1 रंग का उपयोग
स्तर A
जानकारी, सफलता, चेतावनी और त्रुटि शब्दों में लिखे हैं और हर एक का आइकन आकार अलग है; हल्का रंग सिर्फ़ वही दोहराता है जो शब्द कहता है।
-
2.4.3 फ़ोकस क्रम
स्तर A
सूचना खारिज होने पर फ़ोकस पेज के ऊपर गिरने की जगह उस अलर्ट पर जाता है जो उसकी जगह लेता है।
-
3.3.1 त्रुटि पहचान
स्तर A
विफल भुगतान शब्दों में बताया गया है: क्या गलत हुआ, कि कोई पैसा नहीं कटा, और आगे क्या आज़माएँ।
-
4.1.2 नाम, भूमिका, मान
स्तर A
खारिज बटन का नाम खारिज करें और अलर्ट की हेडिंग से बनता है, इसलिए वह बताता है कि कौन सा अलर्ट बंद करता है।
-
4.1.3 स्टेटस मैसेज
स्तर AA
भुगतान की त्रुटि एक role=alert कंटेनर में आती है और फ़ोकस को उस तक ले जाए बिना घोषित होती है।
उपयोग
इसे कब इस्तेमाल करें
इसे अपनाएँ
- पेज पर किसी चीज़ पर ध्यान देना ज़रूरी है: कोई समस्या, कोई जोखिम, सेवा में कोई बदलाव, या यह संकेत कि कोई कदम सफल रहा।
- व्यक्ति के अभी किए किसी काम से हुई त्रुटि, जैसे विफल भुगतान, जिसके बारे में उन्हें अभी सुनना ज़रूरी है।
कुछ और इस्तेमाल करें
- सहेजा गया जैसी आम पुष्टियाँ: polite स्टेटस मैसेज या टोस्ट इस्तेमाल करें, जो बीच में नहीं रोकते।
- फ़ॉर्म फ़ील्ड की त्रुटियाँ: उन्हें फ़ील्ड के पास और त्रुटि सारांश में दिखाएँ, जैसा फ़ॉर्म त्रुटियों वाले पैटर्न में है।
- जिस चीज़ का आगे बढ़ने से पहले जवाब चाहिए: अलर्ट डायलॉग इस्तेमाल करें।
आम विफलताएँ
आमतौर पर यह कहाँ गलत होता है
पहले से मौजूद अलर्ट पर role=alert
पेज लोड होते समय मौजूद अलर्ट ब्राउज़र के हिसाब से या तो बाक़ी सब के ऊपर पढ़ा जाता है या बिल्कुल नहीं। यहाँ स्थिर अलर्ट सादी सामग्री हैं; सिर्फ़ भुगतान की त्रुटि, जो बाद में होती है, लाइव है।
लाइव रीजन को उसके संदेश के साथ जोड़ना
पहले से भरे टेक्स्ट के साथ जोड़ा गया role=alert एलिमेंट कुछ स्क्रीन रीडर और ब्राउज़र जोड़ियों से छूट जाता है। यहाँ खाली कंटेनर शुरू से एचटीएमएल में है, और सिर्फ़ उसकी सामग्री बदलती है।
फ़ोकस को संदेश पर ले जाना
त्रुटि पर कूदने वाला फ़ोकस लोगों को उनके काम से खींच लेता है और उनकी जगह खो देता है। role=alert फ़ोकस जहाँ भी हो, सुनाई देता है।
टोन सिर्फ़ रंग से
रंग-दृष्टि की कमी वाले कई लोगों को, और हर स्क्रीन रीडर को, लाल डिब्बा और हरा डिब्बा एक जैसे लगते हैं। हर अलर्ट अपने टोन को शब्दों में लिखकर शुरू होता है।
बंद करें नाम के बटनों की कतार
कई अलर्ट हों तो बंद करें, बंद करें, बंद करें से पता नहीं चलता कि क्या हटेगा। हर खारिज बटन का नाम खारिज करें और उसके अलर्ट की हेडिंग से बनता है।
हर चीज़ के लिए assertive
हर assertive संदेश स्क्रीन रीडर की चल रही बात काट देता है। role=alert को त्रुटियों और जोखिमों के लिए रखें; पुष्टियाँ polite स्टेटस में जाती हैं।
नोट्स
इसे बनाना
- role=alert का मतलब है aria-live="assertive" और aria-atomic="true": यह बीच में रोकता है और पूरा संदेश पढ़ता है। role=status इसका polite रूप है, जो अगले ठहराव पर पढ़ा जाता है। अकेला aria-live बिना रोल के सिर्फ़ यह तय करता है कि घोषणा कितनी विनम्र हो, उस एलिमेंट के लिए जिसका पहले से कोई रोल है, जैसे कोई सूची।
- लाइव रीजन सिर्फ़ वे बदलाव घोषित करता है जो ब्राउज़र को उसके होने का पता चलने के बाद होते हैं। खाली कंटेनर एचटीएमएल में रखें, फिर संदेश जोड़ें; अपने टेक्स्ट के साथ एक साथ जोड़ा गया रीजन, या उसी पल display: none से दिखाया गया रीजन, अक्सर छूट जाता है। इसीलिए यहाँ कंटेनर कभी छिपाया नहीं जाता, सिर्फ़ खाली रहता है।
- एक ही त्रुटि दो बार घोषित करने के लिए कंटेनर खाली करें और संदेश एक पल बाद जोड़ें: टेक्स्ट को उसी टेक्स्ट से बदलना शायद बदलाव न माना जाए।
- खारिज की गई सूचना को स्टोरेज या खाते में याद रखें, ताकि वह हटी ही रहे। समस्या बनी रहने तक किसी त्रुटि को खारिज करने न दें।
- डेमो में अलर्ट के लिंक # पते इस्तेमाल करते हैं, जहाँ वे दूसरे पेजों की जगह हैं।
स्रोत: WAI-एआरआईए ऑथरिंग प्रैक्टिसेज़: अलर्ट · WAI-एआरआईए 1.2: alert रोल · SC 4.1.3 को समझना: स्टेटस मैसेज
आगे पढ़ें: सिमेंटिक रंग: यूआई में स्टेटस, स्टेट और फीडबैक
लाइट और डार्क थीम में, डेस्कटॉप और फ़ोन की चौड़ाई पर axe से और कीबोर्ड से जाँचा गया। अभी हर स्क्रीन रीडर और ब्राउज़र जोड़ी के साथ नहीं परखा गया। सुधार बताएँ