Problem/Motivation

This is a fairly standard light mode disabled checkbox:
Light Mode Disabled Checkbox

Disabled checkbox in dark mode:
Dark Mode Disabled Checkbox

You can't differentiate visually between the disabled or enabled checkbox.

Steps to reproduce

  1. Go to /admin/modules/uninstall
  2. Switch between light/dark mode
  3. Confirm that it is difficult to see disabled elements

Proposed resolution

Add the CSS to make this stand out better.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3617875

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mgifford created an issue. See original summary.

mgifford’s picture

Disabled controls are legitimate HTML, and poorly styled disabled controls will remain a Drupal accessibility problem.

mgifford’s picture

StatusFileSize
new46.6 KB
new47.84 KB

I'm not sure this is the best approach, but worth putting it out for consideration.

Light Alternative with / through checkbox
Dark Alternative with / through checkbox

/* 1. Define variables for both modes */
:root {
  --control-disabled-text: #5C6670;
  --control-disabled-border: #87909A;
  --control-disabled-background: #E7E9EB;
}

[data-drupal-theme="dark"] {
  --control-disabled-text: #AEB6BF;
  --control-disabled-border: #76818C;
  --control-disabled-background: #30363D;
}

/* 2. Target only form-related elements to prevent affecting layout containers like .region-sticky__items__inner */
input:disabled, 
button:disabled, 
select:disabled, 
textarea:disabled,
[role="checkbox"][aria-disabled="true"],
[role="button"][aria-disabled="true"] {
  color: var(--control-disabled-text);
  border-color: var(--control-disabled-border);
  
  /* Layered background: Red line (gradient) on top of the dynamic background color */
  background: 
    linear-gradient(to top left, transparent calc(50% - 1px), red 50%, transparent calc(50% + 1px)),
    var(--control-disabled-background);

  /* CRITICAL: Allows the gradient to render on native checkbox/radio inputs */
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--control-disabled-border);
  display: inline-block;
  vertical-align: middle;
}

/* 3. Accessibility: Windows High Contrast Mode support */
@media (forced-colors: active) {
  input:disabled, button:disabled, [aria-disabled="true"] {
    forced-color-adjust: auto;
    color: GrayText;
    border-color: GrayText;
    background: none; /* Gradients are usually disabled in HCM for clarity */
  }
}
mgifford’s picture

The red line on black probably doesn't meet color contrast....

mherchel’s picture

It's also not the right size 🤷‍♂️

mgifford’s picture

Status: Active » Needs work
StatusFileSize
new4.77 KB

I failed to create a MR again, so just uploaded this patch. I may have luck with GitLab tomorrow.