सुलभता पैटर्न · इंटरैक्शन और मोशन

फ़ोकस इंडिकेटर

रिंग फ़ोकस रंग की एक आउटलाइन है, जो सतह के रंग के दो घेरों (हेलो) के बीच रहती है, इसलिए पीछे जो भी हो, कोई एक पट्टी उससे अलग दिखती है: हल्का पेज, गहरी पट्टी या ब्रांड रंग की भराई। गैलरी में Tab दबाएँ, और मीटर फ़ोकस वाले एलिमेंट की रिंग मापता है: उसकी चौड़ाई, पृष्ठभूमि के मुक़ाबले उसका कंट्रास्ट और यह कि कुछ उसे ढक तो नहीं रहा।

डब्ल्यूसीएजी मानदंड
5
कीबोर्ड नियम
4
जाँच का तरीक़ा
axe, कीबोर्ड और इंस्पेक्टर

लाइव डेमो

आज़माएँ

इसे माउस, कीबोर्ड या स्क्रीन रीडर से इस्तेमाल करें। साथ का इंस्पेक्टर दिखाता है कि आपके इस्तेमाल के दौरान ब्राउज़र सहायक तकनीक को क्या बताता है: फ़ोकस, स्थिति में बदलाव और घोषणाएँ।

फ़ोकस मीटर

जिस पर भी फ़ोकस हो, उसकी रिंग मापने के लिए Tab दबाएँ।

रिंग की चौड़ाई
–
किनारे से गैप
–
पृष्ठभूमि के मुक़ाबले रिंग
–
पृष्ठभूमि के मुक़ाबले हेलो
–
  • 2.4.7 फ़ोकस दिखाई देता है मापा नहीं गया
  • 1.4.11 गैर-टेक्स्ट कंट्रास्ट मापा नहीं गया
  • 2.4.11 फ़ोकस ढका नहीं मापा नहीं गया
  • 2.4.13 फ़ोकस का रूप मापा नहीं गया

जावास्क्रिप्ट के बिना डेमो उतना ही काम करता है जितना उसका एचटीएमएल; इंस्पेक्टर के लिए जावास्क्रिप्ट चाहिए।

कीबोर्ड

जिन कुंजियों पर यह काम करता है

हर क्रिया पॉइंटर के बिना काम करती है।

कुंजीयह क्या करती है
TabयाShiftTabगैलरी में आगे-पीछे जाता है; जिस पर भी फ़ोकस आए, उस पर दो रंगों की रिंग दिखती है, और मीटर उसे मापता है।
Arrow RightयाArrow Leftमेनू टैब में, अगले या पिछले टैब पर जाता है और उसका पैनल दिखाता है।
HomeयाEndमेनू टैब में, पहले या आख़िरी टैब पर जाता है।
EnterयाSpaceफ़ोकस वाले बटन को चलाता है; Enter लिंक भी खोलता है। उसके बाद भी रिंग उसी एलिमेंट पर रहती है।

स्क्रीन रीडर

यह क्या घोषित करता है

मार्कअप की भूमिकाओं, नामों और स्थितियों से लिखा गया।

कबअपेक्षित घोषणा
फ़ोकस बुकिंग बटन पर पहुँचता हैटेबल बुक करें, बटन
फ़ोकस सहेजें आइकन बटन पर पहुँचता हैसहेजें, टॉगल बटन, दबा हुआ नहीं
फ़ोकस पहले मेनू टैब पर पहुँचता हैदोपहर का खाना, टैब, चयनित, 3 में से 1
फ़ोकस ब्रांड पट्टी वाले कार्ड पर पहुँचता हैआज की थाली, बारह व्यंजन, ₹320, लिंक
रिंग दिखती हैकुछ अतिरिक्त नहीं: रिंग केवल दिखने वाली चीज़ है, पढ़ा जाता है नाम और भूमिका
टेबल बुक होती हैटेबल का अनुरोध भेज दिया गया। हम एक घंटे के अंदर SMS से पुष्टि करेंगे।

ये अपेक्षित घोषणाएँ हैं, रिकॉर्डिंग नहीं। स्क्रीन रीडर और ब्राउज़र के हिसाब से शब्द और क्रम बदलते हैं।

कोड

कोड कॉपी करें

वही फ़ाइलें जिन पर यह डेमो चलता है। स्टाइल एक प्रीफ़िक्स के साथ परोसी जाती हैं जो इस साइट की अपनी स्टाइल को डेमो से दूर रखता है; आप जो कॉपी करते हैं वह मूल है।

मार्कअप

<div class="ap-focus" data-ap-focus-indicator>
  <div class="ap-focus__layout">
    <section class="ap-focus__meter" aria-labelledby="focus-meter-name">
      <div class="ap-focus__meter-top">
        <h3 class="ap-focus__meter-name" id="focus-meter-name">Focus meter</h3>
        <p class="ap-focus__target" data-ap-target><span class="ap-focus__target-idle">Press Tab to measure the ring on whatever has focus.</span></p>
      </div>
      <dl class="ap-focus__nums">
        <div class="ap-focus__num"><dt>Ring width</dt><dd><span data-ap-m="width" translate="no">–</span></dd></div>
        <div class="ap-focus__num"><dt>Gap to the edge</dt><dd><span data-ap-m="gap" translate="no">–</span></dd></div>
        <div class="ap-focus__num"><dt>Ring against background</dt><dd><span class="ap-focus__swatch" data-ap-swatch="ring" aria-hidden="true"></span><span data-ap-m="ring" translate="no">–</span></dd></div>
        <div class="ap-focus__num"><dt>Halo against background</dt><dd><span class="ap-focus__swatch" data-ap-swatch="halo" aria-hidden="true"></span><span data-ap-m="halo" translate="no">–</span></dd></div>
      </dl>
      <ul class="ap-focus__checks">
      <li class="ap-focus__check" data-ap-check="visible" data-state="idle">
        <svg class="ap-focus__mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path class="ap-focus__mark-idle" d="M7 12h10"/><path class="ap-focus__mark-pass" d="m5 12.5 4.5 4.5L19 7.5"/><path class="ap-focus__mark-fail" d="M7 7l10 10M17 7 7 17"/></svg>
        <span class="ap-focus__what"><span class="ap-focus__ref" translate="no">2.4.7</span> <span class="ap-focus__crit">Focus visible</span></span>
        <span class="ap-focus__verdict" data-ap-verdict>Not measured</span>
      </li>
      <li class="ap-focus__check" data-ap-check="contrast" data-state="idle">
        <svg class="ap-focus__mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path class="ap-focus__mark-idle" d="M7 12h10"/><path class="ap-focus__mark-pass" d="m5 12.5 4.5 4.5L19 7.5"/><path class="ap-focus__mark-fail" d="M7 7l10 10M17 7 7 17"/></svg>
        <span class="ap-focus__what"><span class="ap-focus__ref" translate="no">1.4.11</span> <span class="ap-focus__crit">Non-text contrast</span></span>
        <span class="ap-focus__verdict" data-ap-verdict>Not measured</span>
      </li>
      <li class="ap-focus__check" data-ap-check="obscured" data-state="idle">
        <svg class="ap-focus__mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path class="ap-focus__mark-idle" d="M7 12h10"/><path class="ap-focus__mark-pass" d="m5 12.5 4.5 4.5L19 7.5"/><path class="ap-focus__mark-fail" d="M7 7l10 10M17 7 7 17"/></svg>
        <span class="ap-focus__what"><span class="ap-focus__ref" translate="no">2.4.11</span> <span class="ap-focus__crit">Focus not obscured</span></span>
        <span class="ap-focus__verdict" data-ap-verdict>Not measured</span>
      </li>
      <li class="ap-focus__check" data-ap-check="appearance" data-state="idle">
        <svg class="ap-focus__mark" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path class="ap-focus__mark-idle" d="M7 12h10"/><path class="ap-focus__mark-pass" d="m5 12.5 4.5 4.5L19 7.5"/><path class="ap-focus__mark-fail" d="M7 7l10 10M17 7 7 17"/></svg>
        <span class="ap-focus__what"><span class="ap-focus__ref" translate="no">2.4.13</span> <span class="ap-focus__crit">Focus appearance</span></span>
        <span class="ap-focus__verdict" data-ap-verdict>Not measured</span>
      </li>
      </ul>
      <p class="ap-focus__why" data-ap-why></p>
    </section>

    <div class="ap-focus__gallery">
      <p class="ap-focus__bad-note"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 9v4m0 4h.01M10.3 3.9 2.4 18a2 2 0 0 0 1.7 3h15.8a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z"/></svg><span>Bad versions: the link, the button and the tabs have no ring at all, the field, the icon buttons and the card get a faint 1 px ring, and the order list lets focus slide under its sticky bar.</span></p>

      <div class="ap-focus__tile ap-focus__tile--page" role="group" aria-labelledby="focus-cap-page">
        <p class="ap-focus__cap" id="focus-cap-page">On the page surface</p>
        <p class="ap-focus__text">Saffron Table serves Udupi thalis in Indiranagar, Bengaluru. <a class="ap-focus__link" href="#focus-menu">See the full menu</a> before you book.</p>
        <div class="ap-focus__book">
          <div class="ap-field ap-focus__guests">
            <label class="ap-label" for="focus-guests">Guests</label>
            <input class="ap-input" id="focus-guests" type="number" min="1" max="12" value="2" inputmode="numeric" />
          </div>
          <button type="button" class="ap-btn ap-btn--primary" data-ap-book>Book a table</button>
        </div>
      </div>

      <div class="ap-focus__tile ap-focus__tile--invert" role="group" aria-labelledby="focus-cap-invert">
        <div class="ap-focus__tile-top">
          <p class="ap-focus__cap" id="focus-cap-invert">On an inverted band</p>
          <div class="ap-focus__icons">
            <button type="button" class="ap-focus__icon" aria-label="Save" aria-pressed="false" data-ap-save>
              <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M19 21 12 16.5 5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z"/></svg>
            </button>
            <button type="button" class="ap-focus__icon" aria-label="Share" data-ap-share>
              <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><path d="m8.6 13.5 6.8 4M15.4 6.5l-6.8 4"/></svg>
            </button>
          </div>
        </div>
        <div class="ap-focus__tabs" role="tablist" aria-label="Menus">
          <button type="button" class="ap-focus__tab" role="tab" id="focus-tab-lunch" aria-selected="true" aria-controls="focus-panel-lunch">Lunch</button>
          <button type="button" class="ap-focus__tab" role="tab" id="focus-tab-dinner" aria-selected="false" aria-controls="focus-panel-dinner" tabindex="-1">Dinner</button>
          <button type="button" class="ap-focus__tab" role="tab" id="focus-tab-drinks" aria-selected="false" aria-controls="focus-panel-drinks" tabindex="-1">Drinks</button>
        </div>
        <p class="ap-focus__panel" role="tabpanel" id="focus-panel-lunch" aria-labelledby="focus-tab-lunch" tabindex="0">A thali of twelve dishes, served from noon until three.</p>
        <p class="ap-focus__panel" role="tabpanel" id="focus-panel-dinner" aria-labelledby="focus-tab-dinner" tabindex="0" hidden>Dosas and appams to order, from seven until eleven.</p>
        <p class="ap-focus__panel" role="tabpanel" id="focus-panel-drinks" aria-labelledby="focus-tab-drinks" tabindex="0" hidden>Filter coffee, buttermilk and fresh lime soda all day.</p>
      </div>

      <div class="ap-focus__tile ap-focus__tile--brand" role="group" aria-labelledby="focus-cap-brand">
        <p class="ap-focus__cap" id="focus-cap-brand">On the brand color</p>
        <a class="ap-focus__card" href="#focus-thali">
          <svg class="ap-focus__art" viewBox="0 0 96 64" aria-hidden="true" focusable="false"><circle class="ap-focus__plate" cx="48" cy="32" r="29"/><circle class="ap-focus__bowl ap-focus__bowl--a" cx="34" cy="19" r="8"/><circle class="ap-focus__bowl ap-focus__bowl--b" cx="54" cy="16" r="7"/><circle class="ap-focus__bowl ap-focus__bowl--c" cx="66" cy="31" r="7.5"/><ellipse class="ap-focus__rice" cx="42" cy="40" rx="13" ry="9"/><circle class="ap-focus__bowl ap-focus__bowl--a" cx="61" cy="47" r="6"/></svg>
          <span class="ap-focus__card-body">
            <span class="ap-focus__card-name">Thali of the day</span>
            <span class="ap-focus__card-meta">Twelve dishes, ₹320</span>
          </span>
        </a>
        <div class="ap-focus__brand-foot">
          <p class="ap-focus__brand-text">Festive menu from 20 October.</p>
          <button type="button" class="ap-focus__ghost" data-ap-gift>Gift a meal</button>
        </div>
      </div>

      <div class="ap-focus__tile ap-focus__tile--list" role="group" aria-labelledby="focus-cap-list">
        <p class="ap-focus__cap" id="focus-cap-list">In a list with a sticky bar</p>
        <div class="ap-focus__scroll" data-ap-scroll>
          <ul class="ap-focus__orders" aria-label="Your orders">
        <li><a class="ap-focus__order" href="#focus-order-4821"><span class="ap-focus__dish">Masala dosa, two</span> <span class="ap-focus__when">12 Sep · ₹240</span></a></li>
        <li><a class="ap-focus__order" href="#focus-order-4790"><span class="ap-focus__dish">Lunch thali</span> <span class="ap-focus__when">9 Sep · ₹320</span></a></li>
        <li><a class="ap-focus__order" href="#focus-order-4755"><span class="ap-focus__dish">Bisi bele bath</span> <span class="ap-focus__when">4 Sep · ₹180</span></a></li>
        <li><a class="ap-focus__order" href="#focus-order-4712"><span class="ap-focus__dish">Filter coffee, four</span> <span class="ap-focus__when">1 Sep · ₹160</span></a></li>
        <li><a class="ap-focus__order" href="#focus-order-4688"><span class="ap-focus__dish">Neer dosa with curry</span> <span class="ap-focus__when">28 Aug · ₹260</span></a></li>
        <li><a class="ap-focus__order" href="#focus-order-4651"><span class="ap-focus__dish">Mysore pak, half kilo</span> <span class="ap-focus__when">24 Aug · ₹350</span></a></li>
        <li><a class="ap-focus__order" href="#focus-order-4630"><span class="ap-focus__dish">Rava idli, two</span> <span class="ap-focus__when">20 Aug · ₹150</span></a></li>
          </ul>
          <div class="ap-focus__bar">
            <button type="button" class="ap-btn" data-ap-bills>Download bills</button>
          </div>
        </div>
      </div>

      <p class="ap-focus__status" role="status"></p>
    </div>
  </div>
</div>

डब्ल्यूसीएजी 2.2

यह किन मानदंडों को पूरा करता है

वे सफलता मानदंड जिनका यह पैटर्न ध्यान रखता है, और कैसे।

  • 2.4.7 फ़ोकस दिखाई देना स्तर AA

    हर लिंक, बटन, फ़ील्ड, टैब, कार्ड और आइकन बटन कीबोर्ड फ़ोकस मिलने पर रिंग दिखाता है; कहीं भी बिना विकल्प के outline: none नहीं लगाया गया।

  • 1.4.11 गैर-टेक्स्ट कंट्रास्ट स्तर AA

    रिंग और उसका हेलो दो ऐसे रंग हैं जो एक-दूसरे से अलग दिखते हैं, इसलिए हल्के पेज, गहरी पट्टी और ब्रांड रंग, तीनों पर कम से कम एक पट्टी उभरकर दिखती है; मीटर अनुपात दिखाता है।

  • 2.4.11 फ़ोकस अवरुद्ध नहीं (न्यूनतम) स्तर AA

    ऑर्डर सूची में उसकी स्टिकी बार जितना ऊँचा scroll-padding है, इसलिए ब्राउज़र फ़ोकस वाली पंक्ति को बार के नीचे नहीं, उसके ऊपर रोकता है।

  • 2.4.12 फ़ोकस अवरुद्ध नहीं (उन्नत) स्तर AAA

    यही scroll-padding फ़ोकस वाली पूरी पंक्ति को नज़र में रखता है, सिर्फ़ उसका एक हिस्सा नहीं।

  • 2.4.13 फ़ोकस का रूप स्तर AAA

    रिंग एलिमेंट से 2 px बाहर बनी 3 px की आउटलाइन है, जो 2 px की परिधि से ज़्यादा है, और इसकी किसी एक पट्टी के पिक्सेल बिना फ़ोकस वाली पृष्ठभूमि से कम से कम 3:1 बदलते हैं।

उपयोग

इसे कब इस्तेमाल करें

इसे अपनाएँ

  • हर इंटरफ़ेस में: फ़ोकस हो सकने वाले हर एलिमेंट को रिंग चाहिए, और एक साझा स्टाइल सबको एक जैसा रखता है।
  • ऐसे कंपोनेंट जो एक से ज़्यादा पृष्ठभूमि पर आते हैं, जैसे कोई बटन जो सफ़ेद कार्ड, गहरी पट्टियों और ब्रांड रंग, सब पर दिखता है।

कुछ और इस्तेमाल करें

  • क्लिक पर दिखने की वजह से रिंग हटाना: :focus-visible इस्तेमाल करें, जो पॉइंटर क्लिक पर रिंग वैसे भी नहीं दिखाता।
  • सिर्फ़ रंग बदलना, जैसे बटन का थोड़ा गहरा हो जाना: यह रिंग नहीं है, और जो लोग रंगों के हल्के अंतर नहीं पहचान पाते, उनके लिए यह काम नहीं करता।
  • रिंग के तौर पर अकेला box-shadow: फ़ोर्स्ड-कलर्स मोड छायाएँ हटा देता है, इसलिए आउटलाइन रखें।

आम विफलताएँ

आमतौर पर यह कहाँ गलत होता है

  • outline: none, और उसकी जगह कुछ नहीं

    हर जगह से आउटलाइन हटाने वाला रीसेट कीबोर्ड उपयोगकर्ताओं को अंदाज़ा लगाने पर छोड़ देता है कि वे कहाँ हैं। ख़राब संस्करण चालू करें और लिंक व बटन से Tab करके गुज़रें: कुछ नहीं दिखता।

  • ऐसी रिंग जो सिर्फ़ एक पृष्ठभूमि पर काम करे

    इंडिगो बैनर पर इंडिगो रिंग दिखती ही नहीं। सतह के रंग का हेलो रिंग को किसी भी भराई से अलग करता है, जैसा ब्रांड पट्टी में दिखता है।

  • हल्की 1 px की रिंग

    हल्के धूसर रंग की बाल जितनी पतली रेखा तकनीकी रूप से बनी तो है, पर लगभग दिखती नहीं, ख़ासकर हाई-रिज़ॉल्यूशन स्क्रीन पर। 2 px या उससे ज़्यादा इस्तेमाल करें, बगल की चीज़ के मुक़ाबले 3:1 पर।

  • स्टिकी हेडर या फ़ुटर के नीचे फ़ोकस

    ब्राउज़र फ़ोकस वाले एलिमेंट को स्क्रॉल करके नज़र में लाता है, पर स्टिकी बार के नीचे से नहीं निकालता। बार जितना ऊँचा scroll-padding इसे ठीक करता है, स्क्रॉल होने वाले पैनल में भी और पेज पर भी।

  • :focus को स्टाइल करना, फिर उसे हटा देना

    :focus पर बनी रिंग माउस क्लिक के बाद भी दिखती है, इसलिए डिज़ाइनर उसे हटा देते हैं। :focus-visible उसे सिर्फ़ कीबोर्ड और टेक्स्ट फ़ील्ड के लिए दिखाता है।

  • कटी हुई रिंग

    पैरेंट पर लगा overflow: hidden एलिमेंट के बाहर बनी रिंग को काट देता है। कंटेनर में रिंग जितनी चौड़ी पैडिंग दें, या रिंग को अंदर की ओर बनाएँ।

नोट्स

इसे बनाना

  • रिंग है outline: 3px solid var(--ap-focus) और outline-offset: 2px, साथ में var(--ap-surface) रंग के दो box-shadow हेलो: एक 2 px का गैप भरता है, दूसरा रिंग के 2 px बाहर रहता है। फ़ोर्स्ड-कलर्स मोड में छायाएँ हट जाती हैं, पर आउटलाइन बनी रहती है।
  • जिन दो रंगों के बीच कंट्रास्ट C हो, वे किसी भी पृष्ठभूमि पर कम से कम √C की गारंटी देते हैं। इंडिगो और सफ़ेद किसी मध्यम टोन पर सबसे बुरी स्थिति में 2.5:1 देते हैं; लगभग काला और सफ़ेद 4.1:1 देते हैं, इसलिए फ़ोटो पर रिंग के लिए टेक्स्ट का रंग इस्तेमाल करें।
  • स्टिकी बार वाले हर स्क्रॉल कंटेनर पर, और साइट हेडर फ़िक्स्ड हो तो html पर, scroll-padding लगाएँ, ताकि फ़ोकस के साथ होने वाला स्क्रॉल बार से पहले ही रुक जाए।
  • मीटर कंप्यूटेड स्टाइल पढ़ता है: आउटलाइन की चौड़ाई, ऑफ़सेट और रंग, box-shadow से बना हेलो, और एलिमेंट के पीछे की पहली ठोस पृष्ठभूमि। ढके होने की जाँच वह elementFromPoint से करता है, एलिमेंट पर कई बिंदुओं पर पूछकर कि सबसे ऊपर क्या है।
  • डेमो के लिंक #… पर जाते हैं, क्योंकि उनके पेज यहाँ मौजूद नहीं हैं; असली साइट में ये सामान्य लिंक होते हैं।

स्रोत: डब्ल्यूसीएजी 2.2 को समझना: फ़ोकस का रूप · डब्ल्यूसीएजी 2.2 को समझना: फ़ोकस अवरुद्ध नहीं (न्यूनतम) · सीएसएस सेलेक्टर्स लेवल 4: :focus-visible

आगे पढ़ें: सुलभ रंग डिज़ाइन और डब्ल्यूसीएजी कंट्रास्ट

लाइट और डार्क थीम में, डेस्कटॉप और फ़ोन की चौड़ाई पर axe से और कीबोर्ड से जाँचा गया। अभी हर स्क्रीन रीडर और ब्राउज़र जोड़ी के साथ नहीं परखा गया। सुधार बताएँ