You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:58:18