हथकरघा सूती दरी, 4 × 6 फ़ुट
पहले ₹4,200 अब ₹3,400
पानीपत में गड्ढे वाले करघों पर बिना रंगी कपास से बुनी। और पढ़ें: सूती दरी के बारे में
| शहर | पहुँचने में |
|---|---|
| मुंबई | 2 दिन |
| कोच्चि | 4 दिन |
समीक्षाएँ
4.6 (5 में से)
128 समीक्षाएँ
सुलभता पैटर्न · लेआउट और संरचना
कुछ शब्दों की ज़रूरत सिर्फ़ उन लोगों को होती है जो लेआउट नहीं देख सकते: "और पढ़ें" लिंक किसके बारे में है, आइकन बटन क्या करता है, टेबल में क्या है। यूटिलिटी उन्हें हटाने के बजाय एक पिक्सेल में काट देती है, इसलिए स्क्रीन रीडर उन्हें अब भी पढ़ते हैं और बाकी कुछ नहीं बदलता।
लाइव डेमो
इसे माउस, कीबोर्ड या स्क्रीन रीडर से इस्तेमाल करें। साथ का इंस्पेक्टर दिखाता है कि आपके इस्तेमाल के दौरान ब्राउज़र सहायक तकनीक को क्या बताता है: फ़ोकस, स्थिति में बदलाव और घोषणाएँ।
पहले ₹4,200 अब ₹3,400
पानीपत में गड्ढे वाले करघों पर बिना रंगी कपास से बुनी। और पढ़ें: सूती दरी के बारे में
| शहर | पहुँचने में |
|---|---|
| मुंबई | 2 दिन |
| कोच्चि | 4 दिन |
समीक्षाएँ
4.6 (5 में से)
128 समीक्षाएँ
हर स्विच अपने बटन को एक तरीक़े से छिपाता है, और जवाब पेज से मापे जाते हैं। aria-hidden बंद से शुरू होता है: जाल देखने के लिए उसे चालू करें।
सबके लिए ग़ायब, जगह समेत।
सबके लिए ग़ायब, पर उसकी जगह बनी रहती है।
display: none कहने का एचटीएमएल तरीक़ा।
अदृश्य, फिर भी पढ़ा जाता है, क्लिक होता है, और Tab का पड़ाव बना रहता है।
दिखता है पर चुप रहता है। सजावट के लिए सही, फ़ोकस लेने वाली किसी भी चीज़ के लिए ग़लत।
पढ़ा जाता है, दिखता नहीं। फ़ोकस लेने वाली हर चीज़ को फ़ोकस लेने वाला संस्करण चाहिए।
जावास्क्रिप्ट के बिना डेमो उतना ही काम करता है जितना उसका एचटीएमएल; इंस्पेक्टर के लिए जावास्क्रिप्ट चाहिए।
कीबोर्ड
हर क्रिया पॉइंटर के बिना काम करती है।
| कुंजी | यह क्या करती है |
|---|---|
| Tab | शॉप कार्ड के ऊपर से, पहले "समीक्षाओं पर जाएँ" लिंक दिखाता है; फिर कार्ड के लिंक और बटनों से होते हुए तुलना तक ले जाता है। |
| Enter | "समीक्षाओं पर जाएँ" पर फ़ोकस समीक्षाओं पर ले जाता है; "और पढ़ें" पर लिंक खोलता है। |
| Space | "छिपा टेक्स्ट दिखाएँ" पर हर नज़र से छिपा वाक्यांश उसी जगह दिखा देता है; किसी तरीक़े के स्विच पर उसका बटन छिपाकर नतीजा मापता है। |
| EnterयाSpace | दिल वाले बटन पर, दरी को विशलिस्ट में जोड़ता या उससे हटाता है। |
स्क्रीन रीडर
मार्कअप की भूमिकाओं, नामों और स्थितियों से लिखा गया।
| कब | अपेक्षित घोषणा |
|---|---|
| फ़ोकस "और पढ़ें" लिंक पर पहुँचता है | और पढ़ें: सूती दरी के बारे में, लिंक |
| "समीक्षाओं पर जाएँ" पर Enter | समीक्षाएँ, समूह |
| फ़ोकस दिल वाले बटन पर पहुँचता है | विशलिस्ट में सहेजें, टॉगल बटन, दबा नहीं |
| स्क्रीन रीडर पुरानी क़ीमत पढ़ता है | पहले ₹4,200। अब ₹3,400 |
| वह डिलीवरी टेबल पर पहुँचता है | शहर के हिसाब से डिलीवरी का समय, टेबल, 3 पंक्तियाँ, 2 कॉलम |
| aria-hidden वाला स्विच चालू किया जाता है | aria-hidden="true"। दिखता है: हाँ। स्क्रीन रीडर पढ़ते हैं: नहीं। फ़ोकस ले सकता है: हाँ। जगह घेरता है: हाँ। |
ये अपेक्षित घोषणाएँ हैं, रिकॉर्डिंग नहीं। स्क्रीन रीडर और ब्राउज़र के हिसाब से शब्द और क्रम बदलते हैं।
कोड
वही फ़ाइलें जिन पर यह डेमो चलता है। स्टाइल एक प्रीफ़िक्स के साथ परोसी जाती हैं जो इस साइट की अपनी स्टाइल को डेमो से दूर रखता है; आप जो कॉपी करते हैं वह मूल है।
<div class="ap-vh-demo" data-ap-visually-hidden>
<div class="ap-vh-demo__good">
<div class="ap-vh-demo__head">
<h3 class="ap-vh-demo__name" id="vh-good-name">Good uses</h3>
<button type="button" class="ap-vh-demo__switch" role="switch" aria-checked="false" data-vh-reveal>
<span class="ap-vh-demo__track" aria-hidden="true"><span class="ap-vh-demo__knob"></span></span>
Show hidden text
</button>
</div>
<article class="ap-vh-demo__product" aria-labelledby="vh-product-name">
<a class="ap-visually-hidden--focusable ap-vh-demo__skip" href="#vh-reviews">Skip to reviews</a>
<div class="ap-vh-demo__art" aria-hidden="true"></div>
<div class="ap-vh-demo__info">
<div class="ap-vh-demo__row">
<h4 class="ap-vh-demo__product-name" id="vh-product-name">Handloom cotton dhurrie, 4 × 6 ft</h4>
<button type="button" class="ap-vh-demo__icon" aria-pressed="false" data-vh-save>
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10Z"/></svg>
<span class="ap-visually-hidden">Save to wishlist</span>
</button>
</div>
<p class="ap-vh-demo__price">
<s><span class="ap-visually-hidden">Was </span>₹4,200</s>
<strong><span class="ap-visually-hidden">Now </span>₹3,400</strong>
</p>
<p class="ap-vh-demo__blurb">Woven on pit looms in Panipat from undyed cotton. <a href="#vh-dhurrie">Read more<span class="ap-visually-hidden"> about the cotton dhurrie</span></a></p>
<table class="ap-vh-demo__table">
<caption class="ap-visually-hidden">Delivery times by city</caption>
<thead><tr><th scope="col">City</th><th scope="col">Arrives in</th></tr></thead>
<tbody>
<tr><th scope="row">Mumbai</th><td>2 days</td></tr>
<tr><th scope="row">Kochi</th><td>4 days</td></tr>
</tbody>
</table>
<div class="ap-vh-demo__reviews" id="vh-reviews" tabindex="-1" role="group" aria-labelledby="vh-reviews-label">
<p class="ap-vh-demo__rv-label" id="vh-reviews-label">Reviews</p>
<p class="ap-vh-demo__score"><span class="ap-vh-demo__stars" aria-hidden="true">★★★★★</span> 4.6<span class="ap-visually-hidden"> out of 5</span></p>
<p class="ap-vh-demo__count">128 reviews</p>
</div>
</div>
</article>
</div>
<div class="ap-vh-demo__compare">
<h3 class="ap-vh-demo__name" id="vh-compare-name">Six ways to hide, compared</h3>
<p class="ap-vh-demo__intro">Each switch hides its button one way, and the answers are measured from the page. aria-hidden starts off: switch it on to see the trap.</p>
<ul class="ap-vh-demo__grid" role="list">
<li class="ap-vh-demo__card" data-vh-technique="display">
<button type="button" class="ap-vh-demo__switch ap-vh-demo__switch--small" role="switch" aria-checked="true" data-vh-apply>
<span class="ap-vh-demo__track" aria-hidden="true"><span class="ap-vh-demo__knob"></span></span>
<code translate="no">display: none</code>
</button>
<p class="ap-vh-demo__what">Gone for everyone, space and all.</p>
<div class="ap-vh-demo__slot"><button type="button" class="ap-btn ap-vh-demo__specimen is-display">Track order</button></div>
<dl class="ap-vh-demo__out" data-vh-out></dl>
</li>
<li class="ap-vh-demo__card" data-vh-technique="visibility">
<button type="button" class="ap-vh-demo__switch ap-vh-demo__switch--small" role="switch" aria-checked="true" data-vh-apply>
<span class="ap-vh-demo__track" aria-hidden="true"><span class="ap-vh-demo__knob"></span></span>
<code translate="no">visibility: hidden</code>
</button>
<p class="ap-vh-demo__what">Gone for everyone, but its space stays.</p>
<div class="ap-vh-demo__slot"><button type="button" class="ap-btn ap-vh-demo__specimen is-visibility">Track order</button></div>
<dl class="ap-vh-demo__out" data-vh-out></dl>
</li>
<li class="ap-vh-demo__card" data-vh-technique="hidden">
<button type="button" class="ap-vh-demo__switch ap-vh-demo__switch--small" role="switch" aria-checked="true" data-vh-apply>
<span class="ap-vh-demo__track" aria-hidden="true"><span class="ap-vh-demo__knob"></span></span>
<code translate="no">hidden</code>
</button>
<p class="ap-vh-demo__what">The HTML way to say display: none.</p>
<div class="ap-vh-demo__slot"><button type="button" class="ap-btn ap-vh-demo__specimen" hidden>Track order</button></div>
<dl class="ap-vh-demo__out" data-vh-out></dl>
</li>
<li class="ap-vh-demo__card" data-vh-technique="opacity">
<button type="button" class="ap-vh-demo__switch ap-vh-demo__switch--small" role="switch" aria-checked="true" data-vh-apply>
<span class="ap-vh-demo__track" aria-hidden="true"><span class="ap-vh-demo__knob"></span></span>
<code translate="no">opacity: 0</code>
</button>
<p class="ap-vh-demo__what">Invisible, yet still read, still clickable, still a tab stop.</p>
<div class="ap-vh-demo__slot"><button type="button" class="ap-btn ap-vh-demo__specimen is-opacity">Track order</button></div>
<dl class="ap-vh-demo__out" data-vh-out></dl>
</li>
<li class="ap-vh-demo__card" data-vh-technique="aria-hidden">
<button type="button" class="ap-vh-demo__switch ap-vh-demo__switch--small" role="switch" aria-checked="false" data-vh-apply>
<span class="ap-vh-demo__track" aria-hidden="true"><span class="ap-vh-demo__knob"></span></span>
<code translate="no">aria-hidden="true"</code>
</button>
<p class="ap-vh-demo__what">Seen but silent. Right for decoration, wrong for anything focusable.</p>
<div class="ap-vh-demo__slot"><button type="button" class="ap-btn ap-vh-demo__specimen">Track order</button></div>
<dl class="ap-vh-demo__out" data-vh-out></dl>
</li>
<li class="ap-vh-demo__card" data-vh-technique="visually-hidden">
<button type="button" class="ap-vh-demo__switch ap-vh-demo__switch--small" role="switch" aria-checked="true" data-vh-apply>
<span class="ap-vh-demo__track" aria-hidden="true"><span class="ap-vh-demo__knob"></span></span>
<code translate="no">.ap-visually-hidden</code>
</button>
<p class="ap-vh-demo__what">Read, not seen. Anything focusable needs the focusable version.</p>
<div class="ap-vh-demo__slot"><button type="button" class="ap-btn ap-vh-demo__specimen ap-visually-hidden">Track order</button></div>
<dl class="ap-vh-demo__out" data-vh-out></dl>
</li>
</ul>
<p class="ap-visually-hidden" role="status" data-vh-status></p>
</div>
</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; }
}
/* Visually hidden text. Uses the --ap-* design tokens and the shared primitives. */
/* ── The utility ──────────────────────────────────────────────
Read by screen readers, not drawn. Never display: none, which
removes the text from the accessibility tree as well. The
focusable version hides only until it, or something in it, has focus. */
.ap-visually-hidden,
.ap-visually-hidden--focusable:not(:focus, :focus-within) {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
border: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
/* ── The demo ── */
.ap-vh-demo {
display: grid;
gap: 28px;
width: min(100%, 760px);
margin-inline: auto;
container-type: inline-size;
}
.ap-vh-demo__good,
.ap-vh-demo__compare {
display: grid;
gap: 12px;
min-width: 0;
}
.ap-vh-demo__head {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 10px 16px;
}
.ap-vh-demo__name {
margin: 0;
color: var(--ap-text);
font-size: 1.0625rem;
font-weight: 650;
line-height: 1.3;
}
.ap-vh-demo__intro {
margin: -4px 0 2px;
color: var(--ap-text-3);
font-size: .875rem;
line-height: 1.5;
}
/* Switches */
.ap-vh-demo__switch {
display: inline-flex;
align-items: center;
gap: 10px;
min-height: var(--ap-target);
padding: 0 14px 0 10px;
border: 1px solid var(--ap-border-strong);
border-radius: var(--ap-radius);
background: var(--ap-surface);
color: var(--ap-text);
font: inherit;
font-weight: 600;
text-align: start;
cursor: pointer;
}
.ap-vh-demo__switch:hover {
background: var(--ap-surface-2);
}
.ap-vh-demo__switch:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 2px;
}
.ap-vh-demo__switch--small {
width: 100%;
min-height: 40px;
padding-inline: 8px 10px;
border-color: transparent;
background: var(--ap-surface-2);
}
.ap-vh-demo__switch code {
color: var(--ap-text);
font: 600 .8125rem/1.3 var(--ap-mono);
}
.ap-vh-demo__track {
position: relative;
flex-shrink: 0;
width: 36px;
height: 22px;
border: 1px solid var(--ap-border-strong);
border-radius: var(--ap-radius-full);
background: var(--ap-surface-3);
transition: background-color var(--ap-duration) var(--ap-ease), border-color var(--ap-duration) var(--ap-ease);
}
.ap-vh-demo__knob {
position: absolute;
top: 2px;
left: 2px;
width: 16px;
height: 16px;
border-radius: 50%;
background: var(--ap-surface);
box-shadow: 0 0 0 1px var(--ap-border-strong);
transition: transform var(--ap-duration) var(--ap-ease);
}
.ap-vh-demo__switch[aria-checked="true"] .ap-vh-demo__track {
border-color: var(--ap-accent);
background: var(--ap-accent);
}
.ap-vh-demo__switch[aria-checked="true"] .ap-vh-demo__knob {
transform: translateX(14px);
background: var(--ap-on-accent);
box-shadow: none;
}
/* ── Good uses: a product card ── */
.ap-vh-demo__product {
position: relative;
display: grid;
overflow: hidden;
border: 1px solid var(--ap-border);
border-radius: var(--ap-radius-lg);
background: var(--ap-surface);
box-shadow: var(--ap-shadow-md);
}
@container (min-width: 560px) {
.ap-vh-demo__product {
grid-template-columns: 200px minmax(0, 1fr);
}
}
.ap-vh-demo__art {
min-height: 120px;
background:
repeating-linear-gradient(90deg, transparent 0 18px, var(--ap-surface) 18px 20px),
repeating-linear-gradient(0deg, var(--ap-warning) 0 12px, var(--ap-warning-soft) 12px 24px, var(--ap-info) 24px 30px, var(--ap-warning-soft) 30px 42px);
}
.ap-vh-demo__info {
display: grid;
align-content: start;
gap: 10px;
min-width: 0;
padding: 16px 18px 18px;
}
.ap-vh-demo__row {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
}
.ap-vh-demo__product-name {
margin: 0;
color: var(--ap-text);
font-size: 1.125rem;
font-weight: 650;
line-height: 1.3;
}
.ap-vh-demo__icon {
display: grid;
place-items: center;
flex-shrink: 0;
width: 40px;
height: 40px;
margin: -6px -6px 0 0;
padding: 0;
border: 0;
border-radius: 50%;
background: transparent;
color: var(--ap-text-2);
cursor: pointer;
}
.ap-vh-demo__icon:hover {
background: var(--ap-surface-2);
}
.ap-vh-demo__icon:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 2px;
}
.ap-vh-demo__icon svg {
width: 22px;
height: 22px;
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linejoin: round;
}
.ap-vh-demo__icon[aria-pressed="true"] {
color: var(--ap-danger);
}
.ap-vh-demo__icon[aria-pressed="true"] svg {
fill: currentColor;
}
.ap-vh-demo__price {
display: flex;
align-items: baseline;
gap: 10px;
margin: 0;
}
.ap-vh-demo__price s {
color: var(--ap-text-3);
}
.ap-vh-demo__price strong {
color: var(--ap-text);
font-size: 1.125rem;
font-weight: 700;
}
.ap-vh-demo__blurb {
margin: 0;
color: var(--ap-text-2);
line-height: 1.55;
}
.ap-vh-demo__product a {
color: var(--ap-accent-text);
font-weight: 600;
text-decoration: underline;
text-underline-offset: 3px;
}
.ap-vh-demo__product a:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 2px;
border-radius: 3px;
}
.ap-vh-demo__table {
width: 100%;
border-collapse: collapse;
font-size: .875rem;
}
.ap-vh-demo__table th,
.ap-vh-demo__table td {
padding: 6px 0;
border-top: 1px solid var(--ap-border);
text-align: start;
}
.ap-vh-demo__table thead th {
border-top: 0;
color: var(--ap-text-3);
font-size: .75rem;
font-weight: 600;
letter-spacing: .04em;
text-transform: uppercase;
}
.ap-vh-demo__table tbody th {
color: var(--ap-text);
font-weight: 500;
}
.ap-vh-demo__table td {
color: var(--ap-text-2);
text-align: end;
}
.ap-vh-demo__table thead th:last-child {
text-align: end;
}
.ap-vh-demo__reviews {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 4px 10px;
padding: 8px 10px;
border-radius: var(--ap-radius-sm);
background: var(--ap-surface-2);
color: var(--ap-text-2);
font-size: .875rem;
}
.ap-vh-demo__reviews:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 2px;
}
.ap-vh-demo__reviews p {
margin: 0;
}
.ap-vh-demo__rv-label {
color: var(--ap-text);
font-weight: 600;
}
.ap-vh-demo__score {
color: var(--ap-text);
font-weight: 600;
}
.ap-vh-demo__stars {
color: var(--ap-warning);
letter-spacing: 2px;
}
/* The skip link, drawn only while it has focus: its own look goes on
:focus, so the utility's rules are never undone while it is hidden. */
.ap-vh-demo__product .ap-vh-demo__skip:is(:focus, :focus-within) {
position: absolute;
z-index: 2;
top: 10px;
left: 10px;
padding: 8px 14px;
border-radius: var(--ap-radius-sm);
background: var(--ap-surface);
color: var(--ap-accent-text);
box-shadow: var(--ap-shadow-lg);
text-decoration: none;
}
/* Demo only: Show hidden text draws every hidden phrase in place. */
.ap-vh-demo.is-revealed .ap-vh-demo__product .ap-visually-hidden {
position: static;
width: auto;
height: auto;
margin: 0;
overflow: visible;
clip-path: none;
white-space: normal;
padding: 0 3px;
border-radius: 4px;
background: var(--ap-warning-soft);
color: var(--ap-warning);
outline: 1px dashed var(--ap-warning);
font-weight: 600;
}
.ap-vh-demo.is-revealed .ap-vh-demo__table caption.ap-visually-hidden {
margin-bottom: 4px;
padding: 2px 6px;
text-align: start;
}
.ap-vh-demo.is-revealed .ap-vh-demo__icon .ap-visually-hidden {
position: absolute;
top: 100%;
right: 0;
margin-top: 4px;
white-space: nowrap;
font-size: .75rem;
}
.ap-vh-demo.is-revealed .ap-vh-demo__icon {
position: relative;
}
/* ── The comparison ── */
.ap-vh-demo__grid {
display: grid;
gap: 10px;
margin: 0;
padding: 0;
list-style: none;
}
@container (min-width: 420px) {
.ap-vh-demo__grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@container (min-width: 660px) {
.ap-vh-demo__grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
.ap-vh-demo__card {
display: grid;
grid-template-rows: auto auto 1fr auto;
gap: 10px;
min-width: 0;
padding: 10px;
border: 1px solid var(--ap-border);
border-radius: var(--ap-radius);
background: var(--ap-surface);
}
.ap-vh-demo__card[data-trap] {
border-color: var(--ap-danger);
box-shadow: inset 0 3px 0 var(--ap-danger);
}
.ap-vh-demo__what {
margin: 0;
padding: 0 4px;
color: var(--ap-text-3);
font-size: .8125rem;
line-height: 1.45;
}
.ap-vh-demo__slot {
display: grid;
place-items: center;
min-height: 64px;
border: 1px dashed var(--ap-border-strong);
border-radius: var(--ap-radius-sm);
background: var(--ap-surface-2);
}
.ap-vh-demo__specimen.is-display { display: none; }
.ap-vh-demo__specimen.is-visibility { visibility: hidden; }
.ap-vh-demo__specimen.is-opacity { opacity: 0; }
/* The hidden attribute loses to any display rule (.ap-btn sets one). */
.ap-vh-demo__specimen[hidden] { display: none; }
.ap-vh-demo__out {
display: grid;
gap: 0;
margin: 0;
font-size: .8125rem;
}
.ap-vh-demo__out div {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 5px 4px;
border-top: 1px solid var(--ap-border);
}
.ap-vh-demo__out dt {
color: var(--ap-text-2);
}
.ap-vh-demo__out dd {
display: inline-flex;
align-items: center;
gap: 5px;
margin: 0;
color: var(--ap-text);
font-weight: 650;
white-space: nowrap;
}
.ap-vh-demo__out dd::before {
content: "";
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--ap-success);
}
.ap-vh-demo__out dd[data-no]::before {
border-radius: 2px;
background: transparent;
box-shadow: inset 0 0 0 2px var(--ap-text-3);
}
.ap-vh-demo__out div[data-bad] {
border-radius: 4px;
background: var(--ap-danger-soft);
}
.ap-vh-demo__out div[data-bad] :is(dt, dd) {
color: var(--ap-danger);
}
.ap-vh-demo__out div[data-bad] dd::before {
background: var(--ap-danger);
border-radius: 1px;
transform: rotate(45deg);
}
.ap-vh-demo__trap {
margin: 0;
padding: 0 4px;
color: var(--ap-danger);
font-size: .8125rem;
font-weight: 650;
line-height: 1.4;
}
@media (prefers-reduced-motion: reduce) {
.ap-vh-demo__track,
.ap-vh-demo__knob { transition: none; }
}
/**
* Visually hidden text: the utility needs no script. This one runs the demo
* around it: a heart button that toggles, a skip link that moves focus, a
* Show hidden text switch, and a comparison of six ways to hide a button,
* each measured from the live page (seen, read, focusable, takes space).
*
* Markup: [data-ap-visually-hidden] holding button[role=switch][data-vh-reveal],
* button[aria-pressed][data-vh-save], the skip link (.ap-visually-hidden--focusable),
* cards [data-vh-technique] with a switch [data-vh-apply], a button
* .ap-vh-demo__specimen and dl[data-vh-out], and p[role=status][data-vh-status].
*/
/* Each technique, applied to or taken off one element. */
const TECHNIQUES = {
display: (el, on) => el.classList.toggle("is-display", on),
visibility: (el, on) => el.classList.toggle("is-visibility", on),
hidden: (el, on) => { el.hidden = on; },
opacity: (el, on) => el.classList.toggle("is-opacity", on),
"aria-hidden": (el, on) => (on ? el.setAttribute("aria-hidden", "true") : el.removeAttribute("aria-hidden")),
"visually-hidden": (el, on) => el.classList.toggle("ap-visually-hidden", on),
};
const ROWS = [
["visible", "Visible"],
["read", "Read by screen readers"],
["focusable", "Focusable"],
["space", "Takes up space"],
];
/** What the browser makes of an element, read from the page, not assumed. */
function measure(el) {
const box = el.getBoundingClientRect();
const rendered = el.checkVisibility({ visibilityProperty: true });
const drawn = rendered && el.checkVisibility({ opacityProperty: true }) && box.width > 1 && box.height > 1;
return {
visible: drawn,
read: rendered && !el.closest("[aria-hidden='true']"),
focusable: rendered && el.tabIndex >= 0 && !el.disabled && !el.closest("[inert]"),
space: el.checkVisibility() && getComputedStyle(el).position !== "absolute" && box.width > 1,
};
}
function el(tag, className, text) {
const node = document.createElement(tag);
if (className) node.className = className;
if (text != null) node.textContent = text;
return node;
}
export function init(root) {
const reveal = root.querySelector("[data-vh-reveal]");
const status = root.querySelector("[data-vh-status]");
const cards = [...root.querySelectorAll("[data-vh-technique]")];
function paint(card) {
const specimen = card.querySelector(".ap-vh-demo__specimen");
const out = card.querySelector("[data-vh-out]");
const m = measure(specimen);
const trap = m.focusable && (!m.visible || !m.read);
out.replaceChildren();
for (const [key, label] of ROWS) {
const row = el("div");
const dd = el("dd", "", m[key] ? "Yes" : "No");
if (!m[key]) dd.dataset.no = "";
if (trap && (key === "focusable" || !m[key]) && key !== "space") row.dataset.bad = "";
row.append(el("dt", "", label), dd);
out.append(row);
}
card.toggleAttribute("data-trap", trap);
card.querySelector(".ap-vh-demo__trap")?.remove();
if (trap) {
out.after(el("p", "ap-vh-demo__trap", m.read
? "Focusable but invisible: keyboard users lose track of focus."
: "Focusable but silent: screen reader users land on nothing."));
}
return m;
}
/* One status message per change, built from fixed words. */
function announce(card, m) {
status.replaceChildren();
// Each part is one fixed sentence ("Visible: No."), so it translates whole.
const parts = [el("span", "", `${card.querySelector("[data-vh-apply] code").textContent}.`)];
parts[0].setAttribute("translate", "no");
for (const [key, label] of ROWS) parts.push(document.createTextNode(" "), el("span", "", `${label}: ${m[key] ? "Yes" : "No"}.`));
requestAnimationFrame(() => status.append(...parts));
}
function onClick(event) {
const apply = event.target.closest("[data-vh-apply]");
if (apply) {
const card = apply.closest("[data-vh-technique]");
const on = apply.getAttribute("aria-checked") !== "true";
apply.setAttribute("aria-checked", String(on));
TECHNIQUES[card.dataset.vhTechnique](card.querySelector(".ap-vh-demo__specimen"), on);
announce(card, paint(card));
return;
}
if (event.target.closest("[data-vh-reveal]") === reveal) {
const on = reveal.getAttribute("aria-checked") !== "true";
reveal.setAttribute("aria-checked", String(on));
root.classList.toggle("is-revealed", on);
return;
}
const save = event.target.closest("[data-vh-save]");
if (save) {
save.setAttribute("aria-pressed", String(save.getAttribute("aria-pressed") !== "true"));
return;
}
// The skip link moves focus itself, so the address bar is left alone.
const skip = event.target.closest(".ap-visually-hidden--focusable[href^='#']");
if (skip) {
const target = root.querySelector(skip.getAttribute("href"));
if (target) {
event.preventDefault();
target.focus();
}
}
}
for (const card of cards) paint(card);
root.addEventListener("click", onClick);
return () => {
root.removeEventListener("click", onClick);
root.classList.remove("is-revealed");
};
}
for (const root of document.querySelectorAll("[data-ap-visually-hidden]")) 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
वे सफलता मानदंड जिनका यह पैटर्न ध्यान रखता है, और कैसे।
दिल वाले बटन में दिखने वाली चीज़ बस एक आइकन है; नज़र से छिपा टेक्स्ट उसे नाम देता है: विशलिस्ट में सहेजें।
टेबल का कैप्शन बना रहता है और क़ीमतों के साथ "पहले" और "अब" टेक्स्ट में रहते हैं, इसलिए लेआउट जो रिश्ते दिखाता है वे मार्कअप में भी हैं।
"और पढ़ें" छिपे टेक्स्ट में बताता है कि वह किसके बारे में है, इसलिए लिंक की सूची का भी मतलब बनता है।
स्किप लिंक फ़ोकस लेने वाला संस्करण इस्तेमाल करता है, इसलिए फ़ोकस मिलते ही वह पूरा दिखता है; फ़ोकस लेने वाली कोई चीज़ अदृश्य नहीं रहती।
छिपे शब्द दिखने वाले शब्दों के बाद आते हैं (पहले "और पढ़ें", फिर "सूती दरी के बारे में"), ताकि आवाज़ से चलाने वाले वही बोल सकें जो उन्हें दिखता है।
हर स्विच role=switch और aria-checked वाला बटन है, और दिल वाला बटन बताता है कि वह दबा है या नहीं।
हर माप नज़र से छिपे स्टेटस संदेश के ज़रिए भी बोला जाता है, फ़ोकस हिलाए बिना।
उपयोग
आम विफलताएँ
बटन अब भी Tab का पड़ाव है, इसलिए कीबोर्ड उपयोगकर्ता उस पर पहुँचते हैं, और स्क्रीन रीडर कुछ नहीं बोलते या कुछ बेमेल बोलते हैं। उसे सबसे छिपाएँ, या किसी से नहीं।
display: none और visibility: hidden टेक्स्ट को सुलभता ट्री से भी हटा देते हैं, इसलिए स्क्रीन रीडर के लिए लिखे शब्द कभी पढ़े ही नहीं जाते।
left: -9999px तब तक चलता है जब तक अंदर का कोई फ़ोकस लेने वाला एलिमेंट पेज को आड़ा स्क्रॉल न करा दे, या दाएँ से बाएँ वाला लेआउट उसे वापस न ले आए। काटना उसे अपनी जगह रखता है।
अदृश्य एलिमेंट क्लिक और फ़ोकस के लायक बने रहते हैं, इसलिए क्लिक किसी भूत पर पड़ता है और फ़ोकस ग़ायब हो जाता है। उसे हटाएँ या दिखाएँ।
दिखने वाला "ख़रीदें" और छिपा टेक्स्ट "कार्ट में जोड़ें" आवाज़ से चलाने को तोड़ देता है, जो सिर्फ़ वही जानता है जो दिखता है। नाम दिखने वाले शब्दों से शुरू करें।
एलिमेंट पर कोई भी display नियम hidden एट्रिब्यूट के डिफ़ॉल्ट को हरा देता है। जिन एलिमेंट को आप दिखाते और छिपाते हैं, उनके लिए [hidden] { display: none } जोड़ें।
नोट्स
स्रोत: डब्ल्यूसीएजी तकनीक C7: लिंक के टेक्स्ट का हिस्सा छिपाने के लिए सीएसएस · WAI-एआरआईए 1.2: aria-hidden एट्रिब्यूट · एचटीएमएल: hidden एट्रिब्यूट
लाइट और डार्क थीम में, डेस्कटॉप और फ़ोन की चौड़ाई पर axe से और कीबोर्ड से जाँचा गया। अभी हर स्क्रीन रीडर और ब्राउज़र जोड़ी के साथ नहीं परखा गया। सुधार बताएँ