Agent Skills - Phần 7: Web Interface Best Practices
Tài liệu tổng hợp Web Interface Best Practices dùng làm nguồn tham chiếu cho Agent Skills (ví dụ trong Cursor), bao gồm các chủ đề: Accessibility, Focus management, Forms, State & URL management, Performance optimization, Typography và Anti-patterns. Mỗi guideline được đánh giá mức độ quan trọng (Critical/High/Medium/Low) và có ví dụ code cụ thể. Nội dung dựa trên web-interface.csv từ ui-ux-pro-max-skill, giúp developers và AI Agents xây dựng web interface hiệu quả, accessible và performant.
Tài liệu này tổng hợp Web Interface Best Practices dùng làm nguồn tham chiếu cho Agent Skills (ví dụ trong Cursor).
Nội dung dựa trên bộ dữ liệu web-interface.csv từ ui-ux-pro-max-skill.
Cập nhật: 08/02/2026.
Mức độ: 🔴 Critical/High · 🟡 Medium · 🟢 Low
Ví dụ code: + nên · - tránh
1. Accessibility
1.1 🔴 Icon buttons phải có accessible name
Button chỉ có icon nếu không có label sẽ không đọc được với screen reader.
- Nên: Dùng
aria-labelmô tả hành động.
+ <button aria-label="Close">
+ <XIcon />
+ </button>
- Không nên: Icon button không có label.
- <button>
- <XIcon />
- </button>
1.2 🔴 Form control luôn có label
Input không label chỉ rely vào placeholder là không accessible.
- Nên: Dùng
<label>vớifor/idhoặcaria-label.
+ <label for="email">Email</label>
+ <input id="email" type="email" />
- Không nên: Input chỉ có placeholder.
- <input type="email" placeholder="Email" />
1.3 🔴 Interactive element hỗ trợ keyboard
Div click-only không thể focus/trigger bằng keyboard.
- Nên: Thêm
onKeyDown+tabIndex={0}hoặc dùng semantic element.
+ <div onClick={fn} onKeyDown={fn} tabIndex={0}>
+ Clickable
+ </div>
- Không nên: Chỉ handle click chuột.
- <div onClick={fn}>Clickable</div>
1.4 🔴 Ưu tiên semantic HTML hơn ARIA
button, a, label... có behavior + accessibility built-in.
- Nên: Dùng semantic element trước khi thêm ARIA.
+ <button onClick={fn}>Submit</button>
- Không nên: Dùng
div+rolethay vì button thực sự.
- <div role="button" onClick={fn}>Submit</div>
1.5 🟡 Dùng aria-live cho async status
Status async (tải xong, lỗi, saved...) cần được announce cho screen reader.
- Nên: Bọc status trong container
aria-live.
+ <div aria-live="polite">{status}</div>
- Không nên: Chỉ update UI visual, không aria-live.
- <div>{status}</div>
1.6 🟡 Ẩn icon trang trí khỏi screen reader
Icon purely decorative không nên được đọc là “image”.
- Nên: Thêm
aria-hidden="true"hoặcrole="presentation".
+ <Icon aria-hidden="true" />
- Không nên: Để icon không có aria, bị đọc vô nghĩa.
- <Icon />
2. Focus & Keyboard
2.1 🔴 Focus state luôn hiển thị rõ
Interactive elements phải có focus state dễ thấy, nhất là cho keyboard user.
- Nên: Dùng
:focus-visiblevới ring/outline rõ.
+ class="focus-visible:ring-2 focus-visible:ring-blue-500"
- Không nên: Không có bất kỳ focus style nào.
- outline: none; /* không thay thế */
2.2 🔴 Không xoá outline nếu không thay thế
outline: none mà không thêm ring/box-shadow là anti-pattern.
- Nên: Kết hợp
outline-nonevới ring/box-shadow visible.
+ class="focus:outline-none focus:ring-2 focus:ring-blue-500"
- Không nên: Dùng
outline-nonemột mình.
- class="focus:outline-none"
2.3 🟡 Checkbox/radio có vùng hit lớn
Checkbox nhỏ khó click nếu không gắn label tương ứng.
- Nên: Wrap input + label trong cùng
<label>tăng vùng click.
+ <label class="flex gap-2 cursor-pointer">
+ <input type="checkbox" />
+ <span>Option</span>
+ </label>
- Không nên: Input và label tách rời, hit target chỉ là ô nhỏ.
- <input type="checkbox" id="opt" />
- <label for="opt">Option</label>
3. Forms
3.1 🔴 Autocomplete cho input quan trọng
Autofill giúp user nhập nhanh, giảm lỗi.
- Nên: Gán
autocompleteđúng (email,name,new-password, ...).
+ <input autocomplete="email" type="email" />
- Không nên: Bỏ trống
autocompletecho field thường dùng.
- <input type="email" />
3.2 🟡 Dùng input type semantic
Type đúng giúp browser chọn keyboard, validation, autofill phù hợp.
- Nên:
type="email",tel,url,number...
+ <input type="email" />
- Không nên: Dùng
textcho mọi loại input.
- <input type="text" /> <!-- email -->
3.3 🔴 Không block paste (password/code)
Chặn paste làm hại UX, nhất là password manager / mã OTP.
- Nên: Cho phép paste bình thường.
+ <input type="password" />
- Không nên: Ngăn
onPastetrên input.
- <input onPaste={e => e.preventDefault()} />
3.4 🟢 Tắt spellcheck cho email/code
Spellcheck gạch đỏ email, code, ID làm user bối rối.
- Nên:
spellCheck="false"cho field kỹ thuật.
+ <input spellCheck="false" type="email" />
- Không nên: Để spellcheck default cho email/code.
- <input type="email" />