सुलभता पैटर्न · नेविगेशन
खड़े टैब
सेटिंग्स जैसी पट्टी: एक टैब स्टॉप, उसके अंदर ऊपर और नीचे के ऐरो, और aria-orientation="vertical", ताकि सहायक तकनीक जाने कि कौन-से ऐरो सुझाने हैं। जगह कम हो तो पट्टी स्क्रॉल होने वाली पंक्ति बन जाती है, और स्क्रिप्ट दिशा और ऐरो कुंजियों को उसी के हिसाब से बदल देती है।
- डब्ल्यूसीएजी मानदंड
- 6
- कीबोर्ड नियम
- 4
- जाँच का तरीक़ा
- axe, कीबोर्ड और इंस्पेक्टर
लाइव डेमो
आज़माएँ
इसे माउस, कीबोर्ड या स्क्रीन रीडर से इस्तेमाल करें। साथ का इंस्पेक्टर दिखाता है कि आपके इस्तेमाल के दौरान ब्राउज़र सहायक तकनीक को क्या बताता है: फ़ोकस, स्थिति में बदलाव और घोषणाएँ।
सेटिंग्स
अकाउंट
शॉप में आप कैसे दिखते हैं, और आपके ऑर्डर कहाँ जाते हैं।
- नाम
- आशा राव
- सदस्य कब से
- मार्च 2021
- डिलीवरी पता
- कोरेगाँव पार्क, पुणे
- भाषा
- अंग्रेज़ी (भारत)
सूचनाएँ
चुनें कि हम आपको क्या भेजें। सुरक्षा संदेश हमेशा आते हैं।
गोपनीयता
तय करें कि दूसरे खरीदार क्या देखें और चीज़ें सुझाने के लिए हम किसका इस्तेमाल करें।
दिखावट
इस डिवाइस पर शॉप कैसी दिखती है।
बिलिंग
आपकी सदस्यता अपने-आप रिन्यू होती है; आप इसे कभी भी रद्द कर सकते हैं।
- प्लान
- नीला प्लस, सालाना
- अगला भुगतान
- 12 मार्च को ₹1,499
- भुगतान का तरीका
- कार्ड, आख़िरी अंक 4242
जावास्क्रिप्ट के बिना डेमो उतना ही काम करता है जितना उसका एचटीएमएल; इंस्पेक्टर के लिए जावास्क्रिप्ट चाहिए।
कीबोर्ड
जिन कुंजियों पर यह काम करता है
हर क्रिया पॉइंटर के बिना काम करती है।
| कुंजी | यह क्या करती है |
|---|---|
| Tab | टैब सूची में, चुने हुए टैब पर ले जाता है; अगला Tab उसके पैनल में ले जाता है। |
| Arrow DownयाArrow Up | अगले या पिछले टैब पर ले जाता है, सिरों पर घूमकर दूसरी ओर पहुँचता है, और उसका पैनल दिखाता है। |
| HomeयाEnd | पहले या आख़िरी टैब पर ले जाता है। |
| Arrow RightयाArrow Left | कम जगह में पट्टी के पंक्ति बन जाने पर Down और Up वाला ही काम करते हैं। |
स्क्रीन रीडर
यह क्या घोषित करता है
मार्कअप की भूमिकाओं, नामों और स्थितियों से लिखा गया।
| कब | अपेक्षित घोषणा |
|---|---|
| Tab टैब सूची तक पहुँचता है | सेटिंग्स, टैब सूची। अकाउंट, टैब, चयनित, 5 में से 1 |
| Arrow Down अगले टैब पर ले जाता है | सूचनाएँ, टैब, चयनित, 5 में से 2 |
| Tab पैनल में ले जाता है | सूचनाएँ, टैब पैनल |
| पैनल की कोई सेटिंग बंद की जाती है | कीमत घटने पर, चेकबॉक्स, चेक नहीं किया गया |
ये अपेक्षित घोषणाएँ हैं, रिकॉर्डिंग नहीं। स्क्रीन रीडर और ब्राउज़र के हिसाब से शब्द और क्रम बदलते हैं।
कोड
कोड कॉपी करें
वही फ़ाइलें जिन पर यह डेमो चलता है। स्टाइल एक प्रीफ़िक्स के साथ परोसी जाती हैं जो इस साइट की अपनी स्टाइल को डेमो से दूर रखता है; आप जो कॉपी करते हैं वह मूल है।
<div class="ap-vertical-tabs" data-ap-vertical-tabs>
<div class="ap-vertical-tabs__frame">
<div class="ap-vertical-tabs__rail">
<h3 class="ap-vertical-tabs__label" id="vtabs-label">Settings</h3>
<div class="ap-vertical-tabs__list" role="tablist" aria-labelledby="vtabs-label" aria-orientation="vertical">
<button type="button" class="ap-vertical-tabs__tab" role="tab" id="vtabs-tab-account" aria-selected="true" aria-controls="vtabs-panel-account">
<svg class="ap-vertical-tabs__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></svg>
<span>Account</span>
</button>
<button type="button" class="ap-vertical-tabs__tab" role="tab" id="vtabs-tab-notifications" aria-selected="false" aria-controls="vtabs-panel-notifications" tabindex="-1">
<svg class="ap-vertical-tabs__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M6 16V11a6 6 0 0 1 12 0v5l2 2H4Z"/><path d="M10 21h4"/></svg>
<span>Notifications</span>
</button>
<button type="button" class="ap-vertical-tabs__tab" role="tab" id="vtabs-tab-privacy" aria-selected="false" aria-controls="vtabs-panel-privacy" tabindex="-1">
<svg class="ap-vertical-tabs__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 3 5 6v5c0 5 3 8.5 7 10 4-1.5 7-5 7-10V6Z"/><path d="m9 12 2 2 4-4"/></svg>
<span>Privacy</span>
</button>
<button type="button" class="ap-vertical-tabs__tab" role="tab" id="vtabs-tab-appearance" aria-selected="false" aria-controls="vtabs-panel-appearance" tabindex="-1">
<svg class="ap-vertical-tabs__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
<span>Appearance</span>
</button>
<button type="button" class="ap-vertical-tabs__tab" role="tab" id="vtabs-tab-billing" aria-selected="false" aria-controls="vtabs-panel-billing" tabindex="-1">
<svg class="ap-vertical-tabs__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 10h18M7 15h4"/></svg>
<span>Billing</span>
</button>
</div>
</div>
<div class="ap-vertical-tabs__panel" role="tabpanel" id="vtabs-panel-account" aria-labelledby="vtabs-tab-account" tabindex="0">
<h4 class="ap-vertical-tabs__name">Account</h4>
<p class="ap-vertical-tabs__lead">How you appear in the shop, and where your orders go.</p>
<dl class="ap-vertical-tabs__facts">
<div><dt>Name</dt><dd>Asha Rao</dd></div>
<div><dt>Member since</dt><dd>March 2021</dd></div>
<div><dt>Delivery address</dt><dd>Koregaon Park, Pune</dd></div>
<div><dt>Language</dt><dd>English (India)</dd></div>
</dl>
</div>
<div class="ap-vertical-tabs__panel" role="tabpanel" id="vtabs-panel-notifications" aria-labelledby="vtabs-tab-notifications" tabindex="0" hidden>
<h4 class="ap-vertical-tabs__name">Notifications</h4>
<p class="ap-vertical-tabs__lead">Choose what we send you. Security messages always come through.</p>
<div class="ap-vertical-tabs__options">
<div class="ap-vertical-tabs__option">
<input type="checkbox" id="vtabs-orders" aria-describedby="vtabs-orders-hint" checked />
<label for="vtabs-orders">Order updates</label>
<p class="ap-vertical-tabs__hint" id="vtabs-orders-hint">Dispatch, delivery and returns.</p>
</div>
<div class="ap-vertical-tabs__option">
<input type="checkbox" id="vtabs-prices" aria-describedby="vtabs-prices-hint" checked />
<label for="vtabs-prices">Price drops</label>
<p class="ap-vertical-tabs__hint" id="vtabs-prices-hint">When something you saved costs less.</p>
</div>
<div class="ap-vertical-tabs__option">
<input type="checkbox" id="vtabs-news" aria-describedby="vtabs-news-hint" />
<label for="vtabs-news">New arrivals</label>
<p class="ap-vertical-tabs__hint" id="vtabs-news-hint">One email a week, on Fridays.</p>
</div>
</div>
</div>
<div class="ap-vertical-tabs__panel" role="tabpanel" id="vtabs-panel-privacy" aria-labelledby="vtabs-tab-privacy" tabindex="0" hidden>
<h4 class="ap-vertical-tabs__name">Privacy</h4>
<p class="ap-vertical-tabs__lead">Decide what other shoppers see and what we use to suggest things.</p>
<div class="ap-vertical-tabs__options">
<div class="ap-vertical-tabs__option">
<input type="checkbox" id="vtabs-reviews" aria-describedby="vtabs-reviews-hint" checked />
<label for="vtabs-reviews">Show my name on reviews</label>
<p class="ap-vertical-tabs__hint" id="vtabs-reviews-hint">Otherwise reviews show your initials.</p>
</div>
<div class="ap-vertical-tabs__option">
<input type="checkbox" id="vtabs-history" aria-describedby="vtabs-history-hint" />
<label for="vtabs-history">Use my orders for suggestions</label>
<p class="ap-vertical-tabs__hint" id="vtabs-history-hint">Recommendations based on what you bought.</p>
</div>
</div>
</div>
<div class="ap-vertical-tabs__panel" role="tabpanel" id="vtabs-panel-appearance" aria-labelledby="vtabs-tab-appearance" tabindex="0" hidden>
<h4 class="ap-vertical-tabs__name">Appearance</h4>
<p class="ap-vertical-tabs__lead">How the shop looks on this device.</p>
<fieldset class="ap-vertical-tabs__group">
<legend>Theme</legend>
<label class="ap-vertical-tabs__choice"><input type="radio" name="vtabs-theme" value="system" checked /> Match the system</label>
<label class="ap-vertical-tabs__choice"><input type="radio" name="vtabs-theme" value="light" /> Light</label>
<label class="ap-vertical-tabs__choice"><input type="radio" name="vtabs-theme" value="dark" /> Dark</label>
</fieldset>
</div>
<div class="ap-vertical-tabs__panel" role="tabpanel" id="vtabs-panel-billing" aria-labelledby="vtabs-tab-billing" tabindex="0" hidden>
<h4 class="ap-vertical-tabs__name">Billing</h4>
<p class="ap-vertical-tabs__lead">Your membership renews on its own; you can cancel at any time.</p>
<dl class="ap-vertical-tabs__facts">
<div><dt>Plan</dt><dd>Nila Plus, yearly</dd></div>
<div><dt>Next payment</dt><dd>₹1,499 on 12 March</dd></div>
<div><dt>Pay with</dt><dd>Card ending 4242</dd></div>
</dl>
</div>
</div>
</div>
/* Vertical tabs. Uses the --ap-* design tokens. */
.ap-vertical-tabs {
width: min(100%, 720px);
margin-inline: auto;
container-type: inline-size;
}
.ap-vertical-tabs__frame {
display: grid;
grid-template-columns: 210px minmax(0, 1fr);
min-height: 360px;
border: 1px solid var(--ap-border);
border-radius: var(--ap-radius-lg);
background: var(--ap-surface);
box-shadow: var(--ap-shadow-md);
}
/* The rail: a label, then the tabs top to bottom. */
.ap-vertical-tabs__rail {
padding: 16px 10px;
border-right: 1px solid var(--ap-border);
border-radius: var(--ap-radius-lg) 0 0 var(--ap-radius-lg);
background: var(--ap-surface-2);
}
.ap-vertical-tabs__label {
margin: 0 0 10px;
padding: 0 10px;
color: var(--ap-text-3);
font-size: .8125rem;
font-weight: 650;
letter-spacing: .04em;
text-transform: uppercase;
}
.ap-vertical-tabs__list {
display: flex;
flex-direction: column;
gap: 2px;
}
.ap-vertical-tabs__tab {
position: relative;
display: flex;
align-items: center;
gap: 10px;
min-height: 42px;
padding: 0 12px;
border: 1px solid transparent;
border-radius: var(--ap-radius-sm);
background: transparent;
color: var(--ap-text-2);
font: inherit;
font-weight: 500;
text-align: start;
white-space: nowrap;
cursor: pointer;
transition: background-color var(--ap-duration) var(--ap-ease), color var(--ap-duration) var(--ap-ease);
}
.ap-vertical-tabs__tab:hover {
background: var(--ap-surface-3);
color: var(--ap-text);
}
.ap-vertical-tabs__icon {
width: 18px;
height: 18px;
flex-shrink: 0;
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
/* Selected: raised, heavier, and marked with a bar on the inner edge. */
.ap-vertical-tabs__tab[aria-selected="true"] {
border-color: var(--ap-border);
background: var(--ap-surface);
color: var(--ap-text);
font-weight: 650;
box-shadow: var(--ap-shadow-sm);
}
.ap-vertical-tabs__tab[aria-selected="true"] .ap-vertical-tabs__icon {
color: var(--ap-accent-text);
}
.ap-vertical-tabs__tab[aria-selected="true"]::before {
content: "";
position: absolute;
top: 10px;
bottom: 10px;
left: -1px;
width: 3px;
border-radius: 0 3px 3px 0;
background: var(--ap-accent);
}
.ap-vertical-tabs__tab:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 1px;
}
/* A panel: a heading, a line of context, then the settings. */
.ap-vertical-tabs__panel {
padding: 22px 26px 26px;
border-radius: 0 var(--ap-radius-lg) var(--ap-radius-lg) 0;
}
.ap-vertical-tabs__panel:not([hidden]) {
animation: ap-vertical-tabs-in 180ms var(--ap-ease);
}
.ap-vertical-tabs__panel:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: -4px;
}
.ap-vertical-tabs__name {
margin: 0;
font-size: 1.25rem;
font-weight: 650;
line-height: 1.3;
}
.ap-vertical-tabs__lead {
margin: 4px 0 18px;
color: var(--ap-text-2);
line-height: 1.55;
}
.ap-vertical-tabs__facts {
display: grid;
margin: 0;
}
.ap-vertical-tabs__facts div {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 4px 16px;
padding: 11px 0;
border-top: 1px solid var(--ap-border);
}
.ap-vertical-tabs__facts dt {
color: var(--ap-text-3);
}
.ap-vertical-tabs__facts dd {
margin: 0;
color: var(--ap-text);
font-weight: 600;
text-align: end;
}
/* A setting: the box, its label, and a hint under the label. */
.ap-vertical-tabs__options {
display: grid;
}
.ap-vertical-tabs__option {
display: grid;
grid-template-columns: 20px minmax(0, 1fr);
column-gap: 12px;
padding: 12px 0;
border-top: 1px solid var(--ap-border);
}
.ap-vertical-tabs__option input {
width: 18px;
height: 18px;
margin: 2px 0 0;
accent-color: var(--ap-accent);
cursor: pointer;
}
.ap-vertical-tabs__option label {
color: var(--ap-text);
font-weight: 600;
cursor: pointer;
}
.ap-vertical-tabs__hint {
grid-column: 2;
margin: 2px 0 0;
color: var(--ap-text-3);
font-size: .875rem;
line-height: 1.45;
}
.ap-vertical-tabs__group {
display: grid;
gap: 2px;
margin: 0;
padding: 12px 0 0;
border: 0;
border-top: 1px solid var(--ap-border);
}
.ap-vertical-tabs__group legend {
float: left;
width: 100%;
margin-bottom: 6px;
padding: 0;
color: var(--ap-text);
font-weight: 600;
}
.ap-vertical-tabs__choice {
display: flex;
align-items: center;
gap: 12px;
min-height: 40px;
color: var(--ap-text-2);
cursor: pointer;
}
.ap-vertical-tabs__choice input {
width: 18px;
height: 18px;
margin: 0;
accent-color: var(--ap-accent);
cursor: pointer;
}
.ap-vertical-tabs :is(.ap-vertical-tabs__option, .ap-vertical-tabs__choice) input:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 2px;
}
/* Narrow: the rail becomes a row that scrolls sideways on its own,
and the bar moves to the bottom edge. */
@container (max-width: 540px) {
.ap-vertical-tabs__frame {
grid-template-columns: minmax(0, 1fr);
min-height: 0;
}
.ap-vertical-tabs__rail {
padding: 12px 0 0;
border-right: 0;
border-bottom: 1px solid var(--ap-border);
border-radius: var(--ap-radius-lg) var(--ap-radius-lg) 0 0;
}
.ap-vertical-tabs__label {
padding: 0 18px;
margin-bottom: 6px;
}
.ap-vertical-tabs__list {
flex-direction: row;
gap: 4px;
padding: 4px 14px 10px;
overflow-x: auto;
scroll-padding-inline: 14px;
scrollbar-width: thin;
}
/* Room after the last tab, so its focus ring is never cut off at the end. */
.ap-vertical-tabs__list::after {
content: "";
flex: 0 0 4px;
}
.ap-vertical-tabs__tab {
flex: 0 0 auto;
gap: 8px;
min-height: 40px;
padding: 0 12px;
}
.ap-vertical-tabs__tab[aria-selected="true"]::before {
top: auto;
right: 12px;
bottom: -1px;
left: 12px;
width: auto;
height: 3px;
border-radius: 3px 3px 0 0;
}
.ap-vertical-tabs__panel {
padding: 18px 18px 22px;
border-radius: 0 0 var(--ap-radius-lg) var(--ap-radius-lg);
}
}
@keyframes ap-vertical-tabs-in {
from { opacity: 0; transform: translateY(4px); }
}
@media (prefers-reduced-motion: reduce) {
.ap-vertical-tabs__tab { transition: none; }
.ap-vertical-tabs__panel:not([hidden]) { animation: none; }
}
/**
* Vertical tabs: a tab list in a side rail, with one tab stop and the Up
* and Down arrow keys inside it.
*
* Markup: [data-ap-vertical-tabs] holding [role=tablist][aria-orientation]
* with button[role=tab][aria-controls] for each div[role=tabpanel]. When the
* CSS lays the list out as a row (a container query on narrow space), the
* script sets aria-orientation="horizontal" and the Left and Right arrows
* take over from Up and Down.
*/
export function init(root) {
const list = root.querySelector("[role=tablist]");
const tabs = [...list.querySelectorAll("[role=tab]")];
const panelOf = (tab) => document.getElementById(tab.getAttribute("aria-controls"));
function select(tab) {
for (const t of tabs) {
const on = t === tab;
t.setAttribute("aria-selected", String(on));
t.tabIndex = on ? 0 : -1;
panelOf(t).hidden = !on;
}
}
// The orientation follows the layout the CSS chose.
function syncOrientation() {
const row = getComputedStyle(list).flexDirection.startsWith("row");
list.setAttribute("aria-orientation", row ? "horizontal" : "vertical");
}
function onClick(event) {
const tab = event.target.closest("[role=tab]");
if (tab && tabs.includes(tab)) select(tab);
}
function onKeydown(event) {
const at = tabs.indexOf(document.activeElement);
if (at === -1) return;
const vertical = list.getAttribute("aria-orientation") !== "horizontal";
const nextKey = vertical ? "ArrowDown" : "ArrowRight";
const prevKey = vertical ? "ArrowUp" : "ArrowLeft";
let next = null;
if (event.key === nextKey) next = tabs[(at + 1) % tabs.length];
else if (event.key === prevKey) next = tabs[(at - 1 + tabs.length) % tabs.length];
else if (event.key === "Home") next = tabs[0];
else if (event.key === "End") next = tabs[tabs.length - 1];
if (!next) return;
event.preventDefault();
select(next);
next.focus();
// In the scrolling row, keep the whole tab and its focus ring in view
// (scrollIntoView honours the list's scroll-padding; focus alone does not).
next.scrollIntoView({ block: "nearest", inline: "nearest" });
}
const resize = new ResizeObserver(syncOrientation);
resize.observe(root);
list.addEventListener("click", onClick);
list.addEventListener("keydown", onKeydown);
select(tabs.find((t) => t.getAttribute("aria-selected") === "true") || tabs[0]);
syncOrientation();
return () => {
resize.disconnect();
list.removeEventListener("click", onClick);
list.removeEventListener("keydown", onKeydown);
};
}
for (const root of document.querySelectorAll("[data-ap-vertical-tabs]")) 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
रोल टैब को उनके पैनलों से जोड़ते हैं, और aria-orientation बताता है कि सूची ऊपर से नीचे चलती है, इसलिए ढाँचा सिर्फ़ दिखाया नहीं जाता, सहायक तकनीक तक पहुँचता भी है।
-
1.4.1 रंग का उपयोग
स्तर A
चुना हुआ टैब उभरा हुआ है, गाढ़े टेक्स्ट में है और एक पट्टी से चिह्नित है, इसलिए वह रंग पर निर्भर नहीं करता।
-
2.1.1 कीबोर्ड
स्तर A
ऐरो कुंजियाँ, Home और End टैब के बीच ले जाती हैं, और पैनलों के अंदर की हर सेटिंग एक नेटिव फ़ील्ड है।
-
2.4.3 फ़ोकस क्रम
स्तर A
Tab क्रम में सिर्फ़ चुना हुआ टैब है, इसलिए अगला Tab सीधे उसके पैनल में जाता है।
-
2.4.7 फ़ोकस दिखाई देना
स्तर AA
फ़ोकस वाले टैब पर एक रिंग दिखती है, जो पट्टी के सामने 3:1 से ज़्यादा कंट्रास्ट रखती है।
-
4.1.2 नाम, भूमिका, मान
स्तर A
हर टैब पर role=tab और aria-selected है, और हर पैनल का लेबल उसका टैब है।
उपयोग
इसे कब इस्तेमाल करें
इसे अपनाएँ
- पाँच या ज़्यादा सेक्शन वाली सेटिंग्स और प्राथमिकताएँ, जहाँ किनारे की पट्टी में लंबे लेबल के लिए जगह हो।
- ऐसे लेबल जो टैब की एक पंक्ति में बैठने के लिए बहुत लंबे, या बहुत ज़्यादा हों।
कुछ और इस्तेमाल करें
- पेजों के बीच जाना: aria-current से चिह्नित लिंक वाला साइडबार नेविगेशन इस्तेमाल करें।
- दो या तीन सेक्शन: टैब की एक पंक्ति या सेगमेंटेड कंट्रोल हल्का रहता है।
आम विफलताएँ
आमतौर पर यह कहाँ गलत होता है
aria-orientation छूट गया
इसके बिना टैब सूची को आड़ा माना जाता है: स्क्रीन रीडर Left और Right सुझाते हैं, जबकि स्क्रीन पर पट्टी Up और Down के लिए बुलाती है।
लेआउट के साथ न चलने वाली ऐरो कुंजियाँ
जो पट्टी फ़ोन पर पंक्ति बन जाए पर फिर भी सिर्फ़ Up और Down को जवाब दे, वह सबको उलझाती है। यहाँ दिशा और कुंजियाँ, दोनों लेआउट के साथ चलती हैं।
टैब का रूप लिए लिंक
अगर हर आइटम नया पेज खोलता है, तो वह नेविगेशन है: aria-current के साथ nav लैंडमार्क में लिंक, टैब सूची नहीं।
बिना शब्दों के आइकन
सिर्फ़ आइकन वाली पट्टी जगह तो बचाती है, पर लोगों को अंदाज़ा लगाने पर छोड़ देती है। यहाँ हर टैब का अपना शब्द है; आइकन सिर्फ़ सजावट है।
चयन सिर्फ़ रंग से दिखाया गया
हल्के रंग वाला बैकग्राउंड आसानी से नज़र से छूट जाता है। यहाँ चुना हुआ टैब उभरा हुआ, ज़्यादा गाढ़ा और एक पट्टी से चिह्नित है।
नोट्स
इसे बनाना
- कंपोनेंट का आकार बदलने पर स्क्रिप्ट पट्टी का लेआउट पढ़ती है और aria-orientation को “vertical” या “horizontal” पर सेट करती है; ऐरो कुंजियाँ उसी मान के साथ चलती हैं।
- हर पैनल एक हेडिंग और सादे टेक्स्ट से शुरू होता है, इसलिए हर पैनल पर tabindex=0 है और अगला Tab उस तक पहुँचता है।
- यहाँ सेटिंग्स बदलते ही लागू हो जाती हैं। अगर आपकी सेटिंग्स को सहेजें बटन चाहिए, तो उसे हर पैनल के अंदर रखें, ताकि साफ़ रहे कि वह क्या सहेजता है।
- आइकन currentColor से बने aria-hidden एसवीजी हैं, इसलिए दोनों थीम में वे टेक्स्ट के रंग के साथ चलते हैं।
स्रोत: WAI-एआरआईए ऑथरिंग प्रैक्टिसेज़: टैब
लाइट और डार्क थीम में, डेस्कटॉप और फ़ोन की चौड़ाई पर axe से और कीबोर्ड से जाँचा गया। अभी हर स्क्रीन रीडर और ब्राउज़र जोड़ी के साथ नहीं परखा गया। सुधार बताएँ