Skillpedia
المواقع والواجهات (frontend)280k · #182

frontend-a11y

ما الذي تفعله

تساعد هذه المهارة على جعل المواقع والتطبيقات أسهل استعمالًا للجميع، خاصة ذوي الإعاقة. تضمن أن الأزرار والنماذج والعناصر الأخرى تعمل بشكل صحيح مع قارئات الشاشة والتنقل بلوحة المفاتيح.

متى تستخدمها

  • ✓عندما تنشئ نموذجًا في موقع.
  • ✓عندما تضيف أزرارًا تفاعلية أو قوائم.
  • ✓عندما تتلقى تحذيرات إمكانية الوصول في شيفرتك.

رابط المهارة

https://github.com/affaan-m/ECC/blob/main/pi/core/skills/frontend-a11y/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/affaan-m/ECC/blob/main/pi/core/skills/frontend-a11y/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“كيف أجعل نموذج تسجيل الدخول عندي سهل الاستعمال للمستخدمين ضعاف البصر؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يضيف الوكيل مقتطفات شيفرة محددة (مثل «htmlFor» و«aria-label») تساعد قارئات الشاشة على فهم عناصر الصفحة والتفاعل معها. ويقترح أيضًا استعمال وسوم HTML الصحيحة لكل وظيفة.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Frontend Accessibility Patterns

Practical accessibility patterns for React and Next.js. Covers the issues most commonly flagged in code review: missing form labels, incorrect ARIA usage, non-semantic interactive elements, and broken keyboard navigation.

When to Activate

  • Building or reviewing form components (<input>, <select>, <textarea>)
  • Creating interactive elements (modals, dropdowns, tooltips, tabs)
  • Using <div> or <span> with onClick
  • Adding aria-* attributes to any element
  • Implementing keyboard navigation or focus management
  • Receiving accessibility feedback from code review tools (CodeRabbit, ESLint a11y)
  • Building components that must support screen readers

Form Accessibility

Missing htmlFor / id pairing and disconnected error messages are the most common issues flagged in code review.

Label Connection

// BAD: label has no connection to input — screen readers cannot associate them
<label>Email</label>
<input type="email" />

// GOOD: htmlFor matches input id
<label htmlFor="email">Email</label>
<input id="email" type="email" />

Required Fields

// BAD: visual-only asterisk conveys nothing to screen readers
<label htmlFor="email">Email *</label>
<input id="email" type="email" />

// GOOD: required enables native browser validation; aria-required signals it to screen readers
<label htmlFor="email">
  Email <span aria-hidden="true">*</span>
</label>
<input id="email" type="email" required aria-required="true" />

Error Messages

// BAD: error text exists visually but is not linked to the input
<input id="email" type="email" />
<span className="error">Invalid email address</span>

// GOOD: aria-describedby connects input to its error message
// aria-invalid signals the invalid state to screen readers
<input
  id="email"
  type="email"
  aria-describedby="email-error"
  aria-invalid={!!error}
/>
{error && (
  <span id="email-error" role="alert">
    {error}
  </span>
)}

Complete Accessible Form

interface LoginFormProps {
  onSubmit: (email: string, password: string) => void;
}

export function LoginForm({ onSubmit }: LoginFormProps) {
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');
  const [errors, setErrors] = useState<{ email?: string; password?: string }>({});

  const handleSubmit = (e: React.FormEvent) => {
    e.preventDefault();
    const newErrors: typeof errors = {};
    if (!email) newErrors.email = 'Email is required';
    if (!password) newErrors.password = 'Password is required';
    if (Object.keys(newErrors).length) {
      setErrors(newErrors);
      return;
    }
    onSubmit(email, password);
  };

  return (
    <form onSubmit={handleSubmit} noValidate>
      <div>
        <label htmlFor="email">
          Email <span aria-hidden="true">*</span>
        </label>
        <input
          id="email"
          type="email"
          value={email}
          onChange={e => setEmail(e.target.value)}
          aria-required="true"
          aria-describedby={errors.email ? 'email-error' : undefined}
          aria-invalid={!!errors.email}
          autoComplete="email"
        />
        {errors.email && (
          <span id="email-error" role="alert">
            {errors.email}
          </span>
        )}
      </div>

      <div>
        <label htmlFor="password">
          Password <span aria-hidden="true">*</span>
        </label>
        <input
          id="password"
          type="password"
          value={password}
          onChange={e => setPassword(e.target.value)}
          aria-required="true"
          aria-describedby={errors.password ? 'password-error' : undefined}
          aria-invalid={!!errors.password}
          autoComplete="current-password"
        />
        {errors.password && (
          <span id="password-error" role="alert">
            {errors.password}
          </span>
        )}
      </div>

      <button type="submit">Log in</button>
    </form>
  );
}

Semantic HTML

Use the element that matches the intent. Screen readers and keyboard users depend on native semantics.

// BAD: div has no role, no keyboard support, no accessible name
<div onClick={handleClick}>Submit</div>

// GOOD: button is focusable, activates on Enter/Space, announces as "button"
<button type="button" onClick={handleClick}>Submit</button>
// BAD: non-semantic navigation
<div onClick={() => navigate('/home')}>Home</div>


…
الأسئلة الشائعة

ما هي «قارئات الشاشة»؟

هي برامج تقرأ محتوى الشاشة بصوت عالٍ، فتساعد ذوي الإعاقة البصرية على استعمال الحواسيب والهواتف.

لماذا نستعمل «aria-label» أو «htmlFor»؟

هذه الشيفرات تربط التسميات بحقول النموذج أو الأزرار، فتعلن قارئات الشاشة الغرض الصحيح من العنصر.

متى أستعمل `div` مع `onClick`؟

عادة لا ينبغي ذلك. الأفضل استعمال وسم `<button>`، لأنه يتمتع بميزات إمكانية الوصول المدمجة، مثل إمكانية النقر بلوحة المفاتيح.

التفاصيل

الوصف الأصلي من المؤلف

Accessibility patterns for React and Next.js — semantic HTML, ARIA attributes, form labeling, keyboard navigation, focus management, and screen reader support. Use when building or reviewing forms, modals, dropdowns, tooltips, or tabs, fixing a11y lint or code-review findings, or wiring up keyboard navigation and focus management.

repo: affaan-m/ECC

الشعبية

نجوم GitHub
280k
الترتيب
#182
الترخيص
MIT
آخر تحديث
15‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة