惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
Y
Y Combinator Blog
aimingoo的专栏
aimingoo的专栏
B
Blog
小众软件
小众软件
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
L
LangChain Blog
WordPress大学
WordPress大学
罗磊的独立博客
GbyAI
GbyAI
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
雷峰网
雷峰网
美团技术团队
F
Fortinet All Blogs
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How to Build Accessible Custom Dropdowns (Comboboxes) Tha...
Denis Omerov · 2026-04-23 · via DEV Community

Denis Omerovic

Originally published on the AccessGuard blog.

After our post on accessible modals resonated with so many of you, we wanted to tackle another notoriously tricky pattern: the custom dropdown, or combobox. Native select elements are accessible out of the box, but the moment you need custom styling, searchable options, multi-select, or grouped items, you end up reimplementing a lot of browser behavior — and that is where accessibility usually breaks.

This post walks through the pieces you need to get right: semantics, keyboard support, focus management, and announcements. By the end you will have a mental checklist you can apply to any dropdown in your codebase.

Step 1: Start with the right roles

A combobox is not just a styled button. The WAI-ARIA Authoring Practices define a specific role structure: a combobox element (usually a button or input) with aria-haspopup="listbox", aria-expanded reflecting open state, and aria-controls pointing to the listbox id. The popup itself uses role="listbox" and each option uses role="option" with aria-selected on the active option. If you only remember one thing: roles must match behavior. Do not slap role="listbox" on a div that behaves like a menu.

Step 2: Make the trigger reachable and descriptive

The trigger must be a real focusable element — either a native button or an input with tabindex="0". Give it an accessible name using a visible label, aria-label, or aria-labelledby. Announce the current value so screen reader users hear "Country, combobox, United States" and not just "combobox, collapsed."

Step 3: Keyboard support is non-negotiable

This is where most custom dropdowns fail. At a minimum you need: Enter or Space to open the listbox, Arrow Down to open and move to the first or selected option, Arrow Up and Arrow Down to move between options, Home and End to jump to the first and last option, Escape to close and return focus to the trigger, Tab to close and move to the next focusable element, and typeahead so pressing a letter jumps to the next matching option.

Step 4: Manage focus, not just visual highlight

Here is the subtle part. In a listbox pattern, DOM focus stays on the combobox trigger. You do not move focus into the list. Instead, you track the active option with aria-activedescendant, pointing at the id of the currently highlighted option. This keeps typeahead and keyboard handlers on the trigger while still telling assistive tech which option is active. Moving real focus into the list is a common mistake that breaks typeahead and confuses screen readers.

Step 5: Announce changes without being noisy

When the listbox opens, screen readers should announce the expanded state and the active option. You get this for free if aria-expanded and aria-activedescendant are wired up correctly. Avoid adding extra aria-live regions that duplicate this — double announcements are worse than none.

Step 6: Do not forget the close behaviors

Close the listbox on Escape, on outside click, and on blur of the combobox. When closing via Escape, restore focus to the trigger. When a user selects an option, update the trigger's visible text and its accessible name, close the listbox, and return focus to the trigger.

A quick testing checklist

  • Can you open, navigate, select, and close using only the keyboard?
  • Does VoiceOver or NVDA announce the role, state, and active option?
  • Does typeahead work?
  • Does Escape always return focus to the trigger?
  • Do touch users on mobile get a usable experience? (hint: test with TalkBack and VoiceOver on iOS)

If you can answer yes to all of these, you are ahead of 90% of the custom dropdowns on the web.

When to skip all of this

Honestly? Use the native select element whenever you can. It is accessible, it works on every platform, and mobile browsers give you a great picker for free. Only build a custom combobox when you genuinely need features native select cannot provide — searchable options, rich option content, or async loading. The best accessible component is often the one you did not have to build.


We will follow this up with a post on accessible autocompletes, which add another layer of complexity on top of this pattern. If there is a tricky component you would like us to cover next, let us know.

Read more from AccessGuard at getaccessguard.com.