There is a lot of debate surrounding the use of disabled buttons, with many different viewpoints being expressed. However, it is widely agreed that creating an accessible disabled button requires additional code. The standard disabled button may not meet AA compliance standards in terms of color contrast, and its lack of interactivity poses challenges for keyboard users who rely on navigating through elements using their keyboards.
An alternative approach is to avoid using the disabled
attribute and instead assign a disabled class as demonstrated below. By doing so, you have more control over the color contrast, ensuring it meets accessibility requirements while still maintaining the non-clickable functionality desired. This approach also prevents frustration for keyboard users by providing a clear explanation as to why the button is non-interactive.
.disabled {
pointer-events: none;
background-color: your-contrasting-colour-here;
}