सुलभता पैटर्न · ओवरले
अलर्ट डायलॉग
अलर्ट डायलॉग एक मोडल डायलॉग है जो जानबूझकर बीच में रोकता है, ताकि किसी ऐसी चीज़ पर फ़ैसला हो सके जिसे पलटा नहीं जा सकता। इसे नाम दें, सीधे शब्दों में बताएँ कि क्या खो जाएगा, और फ़ोकस उस जवाब पर रखें जिसमें कुछ नहीं खोता।
- डब्ल्यूसीएजी मानदंड
- 6
- कीबोर्ड नियम
- 4
- जाँच का तरीक़ा
- axe, कीबोर्ड और इंस्पेक्टर
लाइव डेमो
आज़माएँ
इसे माउस, कीबोर्ड या स्क्रीन रीडर से इस्तेमाल करें। साथ का इंस्पेक्टर दिखाता है कि आपके इस्तेमाल के दौरान ब्राउज़र सहायक तकनीक को क्या बताता है: फ़ोकस, स्थिति में बदलाव और घोषणाएँ।
ख़तरे का क्षेत्र
यह प्रोजेक्ट हटाएँ
पूरी टीम के लिए मानसून कैंपेन और उसमें मौजूद सब कुछ हटा देता है।
जावास्क्रिप्ट के बिना डेमो उतना ही काम करता है जितना उसका एचटीएमएल; इंस्पेक्टर के लिए जावास्क्रिप्ट चाहिए।
कीबोर्ड
जिन कुंजियों पर यह काम करता है
हर क्रिया पॉइंटर के बिना काम करती है।
| कुंजी | यह क्या करती है |
|---|---|
| EnterयाSpace | प्रोजेक्ट हटाएँ पर, अलर्ट डायलॉग खोलता है और फ़ोकस रद्द करें पर रखता है। |
| TabयाShiftTab | सिर्फ़ डायलॉग के कंट्रोल के बीच चलता है; पीछे के पेज तक नहीं पहुँचा जा सकता। |
| Escape | कुछ भी हटाए बिना डायलॉग बंद करता है और फ़ोकस ट्रिगर पर लौटाता है। |
| Enter | नाम वाले फ़ील्ड में, पुष्टि करता है। अगर नाम मेल नहीं खाता, तो एक त्रुटि दिखती है और फ़ोकस फ़ील्ड में ही रहता है। |
स्क्रीन रीडर
यह क्या घोषित करता है
मार्कअप की भूमिकाओं, नामों और स्थितियों से लिखा गया।
| कब | अपेक्षित घोषणा |
|---|---|
| डायलॉग खुलता है | मानसून कैंपेन हटाएँ?, अलर्ट डायलॉग। यह प्रोजेक्ट, इसकी 48 फ़ाइलें और इसके 3 शेयर किए गए लिंक टीम में सभी के लिए हटा दिए जाएँगे। इसे पलटा नहीं जा सकता। रद्द करें, बटन |
| Tab विनाशकारी बटन तक पहुँचता है | प्रोजेक्ट हटाएँ, बटन |
| टाइप किया गया नाम मेल नहीं खाता | पुष्टि के लिए monsoon-campaign टाइप करें, संपादन बॉक्स, अमान्य प्रविष्टि। प्रोजेक्ट का नाम ठीक वैसे ही टाइप करें जैसा दिखाया गया है। |
| प्रोजेक्ट हट जाता है | प्रोजेक्ट हटा दिया गया |
| डायलॉग रद्द किया जाता है | कुछ भी नहीं हटाया गया |
ये अपेक्षित घोषणाएँ हैं, रिकॉर्डिंग नहीं। स्क्रीन रीडर और ब्राउज़र के हिसाब से शब्द और क्रम बदलते हैं।
कोड
कोड कॉपी करें
वही फ़ाइलें जिन पर यह डेमो चलता है। स्टाइल एक प्रीफ़िक्स के साथ परोसी जाती हैं जो इस साइट की अपनी स्टाइल को डेमो से दूर रखता है; आप जो कॉपी करते हैं वह मूल है।
<div class="ap-alert-dialog" data-ap-alert-dialog>
<div class="ap-alert-dialog__zone">
<div class="ap-alert-dialog__copy">
<p class="ap-alert-dialog__kicker">Danger zone</p>
<h3 class="ap-alert-dialog__zone-name">Delete this project</h3>
<p class="ap-alert-dialog__note">Removes Monsoon campaign and everything in it for the whole team.</p>
</div>
<button type="button" class="ap-btn ap-btn--danger" data-ap-open aria-haspopup="dialog">
<svg class="ap-btn__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 7h16"/><path d="M10 11v6M14 11v6"/><path d="m6 7 1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"/><path d="M9 7V4.5A1.5 1.5 0 0 1 10.5 3h3A1.5 1.5 0 0 1 15 4.5V7"/></svg>
Delete project
</button>
</div>
<p class="ap-alert-dialog__status" role="status"></p>
<dialog class="ap-alert-dialog__dialog" role="alertdialog" aria-labelledby="alert-dialog-name" aria-describedby="alert-dialog-desc">
<form class="ap-alert-dialog__form" method="dialog">
<span class="ap-alert-dialog__icon" aria-hidden="true">
<svg viewBox="0 0 24 24" focusable="false"><path d="M10.3 3.9 2.4 17.6A2 2 0 0 0 4.1 20.6h15.8a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z"/><path d="M12 9.5v4.5"/><path d="M12 17.3h.01"/></svg>
</span>
<h2 class="ap-alert-dialog__name" id="alert-dialog-name">Delete Monsoon campaign?</h2>
<p class="ap-alert-dialog__desc" id="alert-dialog-desc">The project, its 48 files and its 3 shared links will be deleted for everyone on the team. This cannot be undone.</p>
<div class="ap-field ap-alert-dialog__confirm" data-ap-confirm hidden>
<label class="ap-label" for="alert-dialog-confirm">To confirm, type <code>monsoon-campaign</code></label>
<input class="ap-input" id="alert-dialog-confirm" name="confirm" data-ap-expect="monsoon-campaign" autocomplete="off" autocapitalize="off" spellcheck="false" aria-describedby="alert-dialog-error" />
<p class="ap-error" id="alert-dialog-error" data-ap-error hidden>
<svg class="ap-alert-dialog__err" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="9"/><path d="M12 7.5v5"/><path d="M12 16.2h.01"/></svg>
Type the project name exactly as shown.
</p>
</div>
<div class="ap-alert-dialog__actions">
<button type="button" class="ap-btn" data-ap-cancel autofocus>Cancel</button>
<button type="submit" class="ap-btn ap-btn--danger" value="delete">Delete project</button>
</div>
</form>
</dialog>
</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 dialog. Uses the --ap-* design tokens and the shared primitives. */
.ap-alert-dialog {
display: grid;
justify-items: center;
gap: 14px;
}
.ap-alert-dialog [hidden] {
display: none;
}
/* The settings card the trigger lives in */
.ap-alert-dialog__zone {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 18px 28px;
width: min(100%, 580px);
padding: 22px 24px;
border: 1px solid var(--ap-border);
border-radius: var(--ap-radius-lg);
background: var(--ap-surface);
box-shadow: var(--ap-shadow-md);
}
.ap-alert-dialog__copy {
flex: 1 1 250px;
min-width: 0;
}
.ap-alert-dialog__kicker {
margin: 0 0 6px;
color: var(--ap-danger);
font-size: .75rem;
font-weight: 700;
letter-spacing: .08em;
text-transform: uppercase;
}
.ap-alert-dialog__zone-name {
margin: 0 0 4px;
font-size: 1.0625rem;
font-weight: 650;
line-height: 1.35;
}
.ap-alert-dialog__note {
margin: 0;
color: var(--ap-text-3);
line-height: 1.5;
}
.ap-alert-dialog__status {
min-height: 1.5em;
margin: 0;
color: var(--ap-text-2);
font-weight: 600;
}
/* The dialog */
.ap-alert-dialog__dialog {
width: min(100% - 32px, 440px);
max-width: calc(100% - 32px);
max-height: min(100% - 32px, 640px);
padding: 0;
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-lg);
overflow: auto;
opacity: 1;
transform: none;
transition: opacity 180ms var(--ap-ease), transform 180ms var(--ap-ease), overlay 180ms allow-discrete, display 180ms allow-discrete;
}
.ap-alert-dialog__dialog:not([open]) {
opacity: 0;
transform: scale(.96);
}
@starting-style {
.ap-alert-dialog__dialog[open] {
opacity: 0;
transform: scale(.96);
}
}
.ap-alert-dialog__dialog::backdrop {
background: var(--ap-scrim);
backdrop-filter: blur(2px);
transition: opacity 180ms, overlay 180ms allow-discrete, display 180ms allow-discrete;
}
@starting-style {
.ap-alert-dialog__dialog[open]::backdrop { opacity: 0; }
}
.ap-alert-dialog__form {
display: grid;
padding: 24px;
container-type: inline-size;
}
.ap-alert-dialog__icon {
display: grid;
place-items: center;
width: 44px;
height: 44px;
margin-bottom: 16px;
border-radius: var(--ap-radius-full);
background: var(--ap-danger-soft);
color: var(--ap-danger);
}
.ap-alert-dialog__icon svg {
width: 22px;
height: 22px;
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.ap-alert-dialog__name {
margin: 0 0 8px;
font-size: 1.1875rem;
font-weight: 650;
line-height: 1.3;
}
.ap-alert-dialog__desc {
margin: 0;
color: var(--ap-text-2);
line-height: 1.55;
}
.ap-alert-dialog__confirm {
margin-top: 20px;
}
.ap-alert-dialog__confirm code {
padding: 1px 6px;
border-radius: 6px;
background: var(--ap-surface-2);
font-family: var(--ap-mono);
font-size: .875em;
font-weight: 600;
}
.ap-alert-dialog__confirm .ap-input {
font-family: var(--ap-mono);
}
.ap-alert-dialog__err {
width: 16px;
height: 16px;
flex-shrink: 0;
margin-top: 2px;
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
}
.ap-alert-dialog__actions {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 10px;
margin-top: 24px;
}
.ap-alert-dialog__actions .ap-btn {
min-height: var(--ap-target);
}
@container (max-width: 340px) {
.ap-alert-dialog__actions .ap-btn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
.ap-alert-dialog__dialog,
.ap-alert-dialog__dialog::backdrop { transition: none; }
}
/**
* Alert dialog: a modal confirmation before something that cannot be undone,
* on the native dialog element with role=alertdialog.
*
* Markup: [data-ap-alert-dialog] holding a trigger button[data-ap-open], a
* dialog[role=alertdialog][aria-labelledby][aria-describedby] whose
* form[method=dialog] ends with a Cancel button[data-ap-cancel][autofocus]
* and a submit button[value=delete], and a role=status paragraph for the
* outcome. Add data-type-to-confirm to the root to ask for the project's name
* before deleting; the name to match is the field's data-ap-expect.
*/
export function init(root) {
const opener = root.querySelector("[data-ap-open]");
const dialog = root.querySelector("dialog");
const form = dialog.querySelector("form");
const status = root.querySelector("[role=status]");
const confirm = dialog.querySelector("[data-ap-confirm]");
const field = confirm.querySelector("input");
const error = confirm.querySelector("[data-ap-error]");
const html = document.documentElement;
let scrollWas = "";
const typed = () => root.hasAttribute("data-type-to-confirm");
function showError(on) {
error.hidden = !on;
if (on) field.setAttribute("aria-invalid", "true");
else field.removeAttribute("aria-invalid");
}
function open() {
scrollWas = html.style.overflow;
html.style.overflow = "hidden";
status.textContent = "";
confirm.hidden = !typed();
field.value = "";
showError(false);
dialog.returnValue = "";
dialog.showModal();
// autofocus has put focus on Cancel. Typing deletes nothing, so when the
// name is asked for, the field is the safe place to start.
if (typed()) field.focus();
}
// Only the delete button submits; Cancel and Escape close without it.
function onSubmit(event) {
if (!typed() || field.value.trim() === field.dataset.apExpect) return;
event.preventDefault();
showError(true);
field.focus();
}
function onInput() {
if (!error.hidden) showError(false);
}
function onClick(event) {
if (event.target.closest("[data-ap-cancel]")) dialog.close();
}
function onClose() {
html.style.overflow = scrollWas;
status.textContent = dialog.returnValue === "delete" ? "Project deleted" : "Nothing was deleted";
dialog.returnValue = "";
// Browsers do this for modal dialogs; older engines need telling.
opener.focus();
}
opener.addEventListener("click", open);
form.addEventListener("submit", onSubmit);
field.addEventListener("input", onInput);
dialog.addEventListener("click", onClick);
dialog.addEventListener("close", onClose);
return () => {
dialog.removeEventListener("close", onClose);
if (dialog.open) dialog.close();
html.style.overflow = scrollWas;
opener.removeEventListener("click", open);
form.removeEventListener("submit", onSubmit);
field.removeEventListener("input", onInput);
dialog.removeEventListener("click", onClick);
};
}
for (const root of document.querySelectorAll("[data-ap-alert-dialog]")) 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
डायलॉग को नाम उसकी हेडिंग से और विवरण नुकसान बताने वाले पैराग्राफ़ से मिलता है, इसलिए खुलते ही दोनों पढ़े जाते हैं।
-
2.4.3 फ़ोकस क्रम
स्तर A
फ़ोकस रद्द करें से शुरू होता है, यानी उस जवाब से जिसमें कुछ नहीं खोता, और डायलॉग बंद होने पर ट्रिगर पर लौट जाता है।
-
3.3.1 त्रुटि पहचान
स्तर A
मेल न खाने वाला नाम फ़ील्ड के पास शब्दों में और aria-invalid के साथ बताया जाता है, सिर्फ़ लाल बॉर्डर से नहीं।
-
3.3.4 त्रुटि निवारण (क़ानूनी, वित्तीय, डेटा)
स्तर AA
डेटा हटाना साफ़ पुष्टि का इंतज़ार करता है, और ज़्यादा जोखिम वाला संस्करण प्रोजेक्ट का नाम भी माँगता है।
-
4.1.2 नाम, भूमिका, मान
स्तर A
role=alertdialog सहायक तकनीक को बताता है कि यह एक ज़रूरी सवाल है, और dialog एलिमेंट पीछे के पेज को निष्क्रिय रखता है।
-
4.1.3 स्टेटस मैसेज
स्तर AA
नतीजा, हटाया गया या नहीं, एक स्टेटस लाइन में लिखा जाता है, जिसे फ़ोकस हिलाए बिना घोषित किया जाता है।
उपयोग
इसे कब इस्तेमाल करें
इसे अपनाएँ
- किसी ऐसी क्रिया की पुष्टि जो डेटा मिटा दे या पलटी न जा सके, जैसे प्रोजेक्ट हटाना या खाता बंद करना।
- ऐसी समस्या जो फ़ैसला होने तक काम रोक दे, जैसे बिना सहेजे काम के साथ पेज छोड़ना।
कुछ और इस्तेमाल करें
- जो क्रियाएँ पलटी जा सकती हैं: उन्हें तुरंत करें और बदले में पूर्ववत करने का विकल्प दें।
- ऐसी सूचना जिस पर कोई फ़ैसला नहीं लेना: स्टेटस मैसेज या टोस्ट इस्तेमाल करें।
- रोज़मर्रा की क्रियाओं की पुष्टि: लोग बिना पढ़े बटन दबाना सीख जाते हैं, जिससे पुष्टि का मक़सद ही खत्म हो जाता है।
आम विफलताएँ
आमतौर पर यह कहाँ गलत होता है
विनाशकारी बटन पर फ़ोकस
डायलॉग दिखते ही आदतन Enter दबाने वाला व्यक्ति प्रोजेक्ट हटा देता है। यहाँ फ़ोकस रद्द करें से शुरू होता है, इसलिए अनजाने में दबाने से कुछ नहीं खोता।
एक अस्पष्ट सवाल
OK और Cancel के साथ "क्या आप पक्का हैं?" यह नहीं बताता कि क्या होगा। यहाँ हेडिंग प्रोजेक्ट का नाम लेती है, विवरण बताता है कि क्या खोएगा, और बटन पर लिखा है प्रोजेक्ट हटाएँ।
कोई विवरण नहीं
aria-describedby के बिना डायलॉग खुलने पर सिर्फ़ हेडिंग घोषित होती है, और नतीजा वही सुन पाता है जो उसे ढूँढने जाए।
भटके हुए क्लिक पर बंद होना
डायलॉग के बाहर क्लिक कोई जवाब नहीं है। यह डायलॉग सिर्फ़ अपने दो बटनों या Escape से बंद होता है, और Escape का मतलब हमेशा रद्द करना है।
बिना कारण धूसर किया गया बटन
निष्क्रिय किया गया हटाने का बटन कोई संकेत नहीं देता कि वह किस चीज़ का इंतज़ार कर रहा है, और कई स्क्रीन रीडर उसे छोड़ देते हैं। यहाँ बटन हमेशा काम करता है और बताता है कि क्या गलत है।
डायलॉग की जगह role=alert
role=alert एक संदेश को एक बार पढ़ देता है, लेकिन न तो फ़ोकस को उसके बटनों तक ले जाता है और न ही पीछे के पेज को पहुँच से बाहर रखता है। अलर्ट डायलॉग दोनों करता है।
नोट्स
इसे बनाना
- dialog एलिमेंट पर role=alertdialog उसकी भूमिका बदल देता है, लेकिन showModal() से मिलने वाला सब कुछ बना रहता है: टॉप लेयर, निष्क्रिय पेज और Escape।
- autofocus एट्रिब्यूट फ़ोकस रद्द करें पर रखता है। नाम की जाँच चालू होने पर स्क्रिप्ट फ़ोकस फ़ील्ड में ले जाती है, क्योंकि टाइप करने से कुछ नहीं हटता।
- विनाशकारी बटन पर क्रिया का नाम लिखें, "प्रोजेक्ट हटाएँ", "OK" या "हाँ" नहीं, ताकि सीधे उस तक Tab करने वाले को भी उसका मतलब समझ आए।
- लाइट डिसमिस बंद रखें: इतने बड़े फ़ैसले के लिए साफ़ जवाब चाहिए, और स्टेटस लाइन पुष्टि करती है कि कौन-सा जवाब दिया गया।
स्रोत: WAI-एआरआईए ऑथरिंग प्रैक्टिसेज़: अलर्ट और मैसेज डायलॉग · WAI-एआरआईए 1.2: alertdialog भूमिका
लाइट और डार्क थीम में, डेस्कटॉप और फ़ोन की चौड़ाई पर axe से और कीबोर्ड से जाँचा गया। अभी हर स्क्रीन रीडर और ब्राउज़र जोड़ी के साथ नहीं परखा गया। सुधार बताएँ