सुलभता पैटर्न · फ़ॉर्म इनपुट

रेडियो कार्ड

हर कार्ड एक असली रेडियो बटन के चारों ओर लिपटा लेबल है, इसलिए उस पर कहीं भी क्लिक करने से प्लान चुना जाता है, और ऐरो कुंजियाँ प्लानों के बीच वैसे ही चलती हैं जैसे किसी भी रेडियो ग्रुप में। रेडियो का नाम प्लान और उसकी कीमत से बनता है और विवरण उसकी सुविधाओं से, इसलिए पूरा कार्ड एक लंबा नाम बने बिना पूरा पढ़ा जाता है।

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

लाइव डेमो

आज़माएँ

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

कोई प्लान चुनें

कीमतों में GST शामिल है। कभी भी बदलें या रद्द करें।

आज देय ₹499

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

कीबोर्ड

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

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

कुंजीयह क्या करती है
Tabचुने हुए प्लान पर जाता है, या कुछ न चुना हो तो पहले प्लान पर; अगला Tab ग्रुप से बाहर ले जाता है।
Arrow DownयाArrow Rightअगला प्लान चुनता है, आख़िरी से घूमकर पहले पर पहुँचता है।
Arrow UpयाArrow Leftपिछला प्लान चुनता है, पहले से घूमकर आख़िरी पर पहुँचता है।
Spaceअगर अभी कुछ नहीं चुना गया है, तो फ़ोकस वाला प्लान चुनता है।
Enterकिसी प्लान पर, फ़ॉर्म भेजता है, ठीक वैसे ही जैसे जारी रखें दबाना।

स्क्रीन रीडर

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

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

कबअपेक्षित घोषणा
Tab ग्रुप पर पहुँचता हैप्लान चुनें, समूह। कीमतों में GST शामिल है। स्टूडियो ₹499 हर महीने, रेडियो बटन, चुना हुआ, 3 में से 2। लोकप्रिय। फ़्रीलांसरों और छोटे स्टूडियो के लिए।
Arrow Down अगला प्लान चुनता हैटीम ₹1,299 हर महीने, रेडियो बटन, चुना हुआ, 3 में से 3। दस लोगों तक की टीमों के लिए। स्टूडियो का सब कुछ…
कुछ चुने बिना जारी रखें दबाया जाता हैफ़ोकस स्टार्टर पर जाता है: प्लान चुनें, समूह। जारी रखने के लिए कोई प्लान चुनें। स्टार्टर ₹0 हर महीने, रेडियो बटन, चुना नहीं गया, 3 में से 1
प्लान चुनकर जारी रखें दबाया जाता हैचुना गया प्लान: टीम

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

कोड

कोड कॉपी करें

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

मार्कअप

<form class="ap-radio-cards" data-ap-radio-cards novalidate>
  <fieldset class="ap-radio-cards__set" aria-describedby="radio-cards-hint">
    <legend class="ap-radio-cards__legend">Choose a plan</legend>
    <p class="ap-radio-cards__hint" id="radio-cards-hint">Prices include GST. Change or cancel at any time.</p>
    <p class="ap-error ap-radio-cards__error" id="radio-cards-error" hidden>
      <svg class="ap-radio-cards__error-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="9"/><path d="M12 7.5v5.5M12 16.5h.01"/></svg>
      <span>Choose a plan to continue.</span>
    </p>
    <div class="ap-radio-cards__grid">
      <label class="ap-radio-cards__card">
        <input class="ap-radio-cards__radio" type="radio" name="radio-cards-plan" value="starter" aria-labelledby="radio-cards-starter-name radio-cards-starter-price" aria-describedby="radio-cards-starter-fit radio-cards-starter-features" />
        <span class="ap-radio-cards__top">
          <span class="ap-radio-cards__name" id="radio-cards-starter-name">Starter</span>
          <span class="ap-radio-cards__mark" aria-hidden="true"><svg viewBox="0 0 24 24" focusable="false"><path d="m6.5 12.5 3.5 3.5 7.5-8"/></svg></span>
        </span>
        <span class="ap-radio-cards__price" id="radio-cards-starter-price"><span class="ap-radio-cards__amount">₹0</span> <span class="ap-radio-cards__per">a month</span></span>
        <span class="ap-radio-cards__fit" id="radio-cards-starter-fit">For trying it out on your own.</span>
        <span class="ap-radio-cards__features" id="radio-cards-starter-features">
          <span class="ap-radio-cards__feature"><svg class="ap-radio-cards__tick" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg>3 projects</span>
          <span class="ap-radio-cards__feature"><svg class="ap-radio-cards__tick" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg>2 GB storage</span>
          <span class="ap-radio-cards__feature"><svg class="ap-radio-cards__tick" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg>Community help</span>
        </span>
      </label>
      <label class="ap-radio-cards__card">
        <input class="ap-radio-cards__radio" type="radio" name="radio-cards-plan" value="studio" aria-labelledby="radio-cards-studio-name radio-cards-studio-price" aria-describedby="radio-cards-studio-badge radio-cards-studio-fit radio-cards-studio-features" checked />
        <span class="ap-radio-cards__top">
          <span class="ap-radio-cards__name" id="radio-cards-studio-name">Studio</span>
          <span class="ap-radio-cards__badge" id="radio-cards-studio-badge"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m12 3.5 2.6 5.3 5.9.9-4.25 4.1 1 5.8L12 16.85 6.75 19.6l1-5.8L3.5 9.7l5.9-.9Z"/></svg>Popular</span>
          <span class="ap-radio-cards__mark" aria-hidden="true"><svg viewBox="0 0 24 24" focusable="false"><path d="m6.5 12.5 3.5 3.5 7.5-8"/></svg></span>
        </span>
        <span class="ap-radio-cards__price" id="radio-cards-studio-price"><span class="ap-radio-cards__amount">₹499</span> <span class="ap-radio-cards__per">a month</span></span>
        <span class="ap-radio-cards__fit" id="radio-cards-studio-fit">For freelancers and small studios.</span>
        <span class="ap-radio-cards__features" id="radio-cards-studio-features">
          <span class="ap-radio-cards__feature"><svg class="ap-radio-cards__tick" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg>Unlimited projects</span>
          <span class="ap-radio-cards__feature"><svg class="ap-radio-cards__tick" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg>100 GB storage</span>
          <span class="ap-radio-cards__feature"><svg class="ap-radio-cards__tick" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg>Email support within a day</span>
        </span>
      </label>
      <label class="ap-radio-cards__card">
        <input class="ap-radio-cards__radio" type="radio" name="radio-cards-plan" value="team" aria-labelledby="radio-cards-team-name radio-cards-team-price" aria-describedby="radio-cards-team-fit radio-cards-team-features" />
        <span class="ap-radio-cards__top">
          <span class="ap-radio-cards__name" id="radio-cards-team-name">Team</span>
          <span class="ap-radio-cards__mark" aria-hidden="true"><svg viewBox="0 0 24 24" focusable="false"><path d="m6.5 12.5 3.5 3.5 7.5-8"/></svg></span>
        </span>
        <span class="ap-radio-cards__price" id="radio-cards-team-price"><span class="ap-radio-cards__amount">₹1,299</span> <span class="ap-radio-cards__per">a month</span></span>
        <span class="ap-radio-cards__fit" id="radio-cards-team-fit">For teams of up to ten people.</span>
        <span class="ap-radio-cards__features" id="radio-cards-team-features">
          <span class="ap-radio-cards__feature"><svg class="ap-radio-cards__tick" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg>Everything in Studio</span>
          <span class="ap-radio-cards__feature"><svg class="ap-radio-cards__tick" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg>Shared folders</span>
          <span class="ap-radio-cards__feature"><svg class="ap-radio-cards__tick" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg>Phone support</span>
        </span>
      </label>
    </div>
  </fieldset>
  <div class="ap-radio-cards__foot">
    <p class="ap-radio-cards__total"><span class="ap-radio-cards__total-k">Due today</span> <strong class="ap-radio-cards__total-v" data-ap-total translate="no">₹499</strong></p>
    <button type="submit" class="ap-btn ap-btn--primary">Continue</button>
  </div>
  <p class="ap-radio-cards__status" role="status"></p>
</form>

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

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

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

  • 1.3.1 जानकारी और संबंध स्तर A

    fieldset और legend तीनों प्लानों को एक समूह बनाते हैं और उसे नाम देते हैं, और हर रेडियो aria-labelledby और aria-describedby से अपने नाम, कीमत और सुविधाओं से जुड़ा है।

  • 1.4.1 रंग का उपयोग स्तर A

    चुने हुए कार्ड पर भरा हुआ सही का निशान और दो पिक्सेल का किनारा आता है, इसलिए चुनाव कभी सिर्फ़ उसके हल्के रंग पर निर्भर नहीं होता।

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

    ख़ाली निशान वाला गोला और चुने हुए कार्ड का किनारा, दोनों कार्ड के मुक़ाबले 3:1 पार करते हैं, इसलिए हर प्लान की स्थिति दिखती है।

  • 2.1.1 कीबोर्ड स्तर A

    नेटिव रेडियो बटन Tab और ऐरो कुंजियों का जवाब देते हैं, इसलिए कार्डों को अपनी कोई कुंजी-व्यवस्था नहीं चाहिए।

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

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

  • 3.3.1 त्रुटि पहचान स्तर A

    कुछ चुने बिना आगे बढ़ने पर टेक्स्ट में संदेश दिखता है, वह ग्रुप के विवरण में जुड़ जाता है, और फ़ोकस पहले प्लान पर चला जाता है।

  • 4.1.2 नाम, भूमिका, मान स्तर A

    हर प्लान एक असली रेडियो इनपुट है, इसलिए उसकी भूमिका, नाम, चुनी हुई स्थिति और सेट में जगह ब्राउज़र से आती है।

उपयोग

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

इसे अपनाएँ

  • दो से चार विकल्पों में से चुनाव, जिनमें हर एक को कुछ पंक्तियों का ब्योरा चाहिए, जैसे प्लान, डिलीवरी की रफ़्तार या सीट की श्रेणी।
  • ऐसा फ़ैसला जिसे लोग साथ-साथ रखकर तुलना करते हैं, और जहाँ ब्योरा चुनने में मदद करता है।

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

  • छोटे विकल्प जिन्हें ब्योरे की ज़रूरत नहीं: साधारण रेडियो ग्रुप जल्दी देखा और पढ़ा जाता है।
  • एक साथ कई चीज़ें चुनना: चेकबॉक्स इस्तेमाल करें, चाहें तो कार्ड की तरह सजाकर।
  • विकल्पों की लंबी सूची: select या कॉम्बोबॉक्स इस्तेमाल करें।

आम विफलताएँ

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

  • रेडियो की जगह क्लिक होने वाले div

    क्लिक हैंडलर वाले div से बने कार्ड Tab से नहीं पहुँचे जा सकते, ऐरो कुंजियों का जवाब नहीं देते और चुने जाने के बारे में कुछ नहीं बताते। हर कार्ड के अंदर एक असली रेडियो यह सब ले आता है।

  • display: none से छिपाया गया रेडियो

    display: none रेडियो को Tab क्रम और सुलभता ट्री, दोनों से हटा देता है, इसलिए कार्ड ठीक दिखते हैं पर कीबोर्ड से किसी के लिए काम नहीं करते। यहाँ वह पारदर्शी है और निशान वाले गोले के ऊपर रखा है।

  • पूरा कार्ड ही नाम

    सब कुछ लपेटने वाला लेबल रेडियो के नाम को कीमतों और सुविधाओं का एक अनुच्छेद बना देता है। aria-labelledby नाम को प्लान और कीमत तक सीमित रखता है; बाक़ी उसका विवरण है।

  • चुनाव सिर्फ़ हल्के रंग से दिखाना

    पृष्ठभूमि का हल्का बदलाव कई लोगों को दिखता ही नहीं और फ़ोर्स्ड कलर मोड में पूरी तरह ग़ायब हो जाता है। यहाँ चुने हुए कार्ड पर सही का निशान और गाढ़ा किनारा भी आता है।

  • कार्ड पर कोई फ़ोकस रिंग नहीं

    जब असली इनपुट दिखता नहीं, तो उसकी फ़ोकस रिंग भी नहीं दिखती। यहाँ रिंग :has(:focus-visible) से कार्ड के चारों ओर बनाई जाती है।

नोट्स

इसे बनाना

  • label एलिमेंट में सिर्फ़ फ़्रेज़िंग कंटेंट रह सकता है, इसलिए कार्ड के अंदर सब कुछ ब्लॉक की तरह दिखाया गया span है; वहाँ div या ul अमान्य एचटीएमएल है।
  • रेडियो ग्रुप में ऐरो कुंजियाँ चलते-चलते चुनती हैं। यह ऐसे चुनने वाले के लिए ठीक है, जहाँ फ़ॉर्म भेजे जाने तक चुनने से कुछ नहीं बदलता।
  • निशान वाला गोला रेडियो का अपना बॉक्स है: पारदर्शी इनपुट ठीक उसके ऊपर रखा है, इसलिए स्क्रीन मैग्निफ़ायर और टच से खोजने वाले उसे वहीं पाते हैं जहाँ आँख पाती है।
  • जब कोई समझदारी भरा प्लान हो, तो उसे पहले से चुना रहने दें। ऊपर का विकल्प कुछ भी चुने बिना शुरू होता है, ताकि बिना चुने जारी रखें दबाने पर त्रुटि दिखे।
  • त्रुटि fieldset के aria-describedby में सिर्फ़ तभी जुड़ती है जब वह दिख रही हो: aria-describedby जिस छिपे हुए एलिमेंट की ओर इशारा करता है, वह भी पढ़ा जाता है।

स्रोत: WAI-एआरआईए ऑथरिंग प्रैक्टिसेज़: रेडियो ग्रुप · एचटीएमएल: label एलिमेंट

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