Web无障碍:日期选择器禁用日期/月份是否需设置aria-disabled='true'
日期选择器(Date Picker)无障碍整改指南
Hey folks, let's walk through the specific accessibility fixes your date picker needs based on the expert's audit feedback:
核心规范要求
- 必须使用ARIA角色与属性来明确日期选择器的语义结构,具体细节可参考附录A《无障碍日期选择器要求》
- 禁用状态标识:如果某个月份或日期选项处于禁用状态,一定要在对应的可交互元素上设置
aria-disabled="true"属性,让辅助技术能识别到该元素不可用
代码示例参考
<label for="date-picker-input">Date:</label> <input type="text" id="date-picker-input" aria-haspopup="dialog" aria-expanded="false" aria-controls="date-picker-container" > <div id="date-picker-container" role="dialog" aria-modal="true" aria-labelledby="date-picker-input" > <!-- 禁用月份示例 --> <button aria-disabled="true">January</button> <button>February</button> <!-- 禁用日期示例 --> <button aria-disabled="true">1</button> <button>2</button> </div>
内容的提问来源于stack exchange,提问作者seal
相关产品推荐
相关产品推荐

