Opened 6 weeks ago

Last modified 3 weeks ago

#35888 assigned Bug

Color contrast issues for admin icons

Reported by: Thibaud Colas Owned by: Sarah Sanger
Component: contrib.admin Version: 5.0
Severity: Normal Keywords: accessibility, contrast, icons, wcag, svg
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: yes

Description (last modified by Thibaud Colas)

There are a lot of icons in the Django admin that don’t have enough contrast against their background. This is particularly the case for icons used as part of the messages functionality of Django, though this is present in a lot of other icons across the admin.

Here are examples:

  • "Success" check icon, #70bf2b on #dfd, contrast of 2.11:1
  • "Warning" icon, #efb80b on #ffc, contrast of 1.77:1

Here’s a representation of all theoretical contrast issues (large image):

https://code.djangoproject.com/raw-attachment/ticket/35888/Django%20icons%20color%20contrast%20issues.png

Link to the demo page I used to test this: django-admin-tests styleguide.

For icons, per WCAG SC 1.4.11 Non-text Contrast, the minimum required "icon to background" contrast is 3:1. However I’d argue it would be better for end users and simpler for contributors to manage if Django used the same 4.5:1 minimum as SC 1.4.3 Contrast (Minimum) (meant for text). While 3:1 could be enough in some cases, Django has quite a lot of UI components that are identified by icons only, and those icons tend to be small.

---

To fix this, I would recommend to start a transition away from icons as external files. With more modern approaches to icons definitions, it’ll be possible to better style the icon graphics according to the UI component state and admin theming.

For the problem at hand – it’ll be sufficient to do a first step of converting all icons defined in CSS with the background or background-image properties, to the mask-image property. This makes it possible to define the icon’s color in CSS, so we can then apply theme-specific colors for the icons.

Note for some of the icons – this will require moving away from sprite techniques.

Attachments (1)

Django icons color contrast issues.png (107.6 KB ) - added by Thibaud Colas 6 weeks ago.

Download all attachments as: .zip

Change History (6)

by Thibaud Colas, 6 weeks ago

comment:1 by Thibaud Colas, 6 weeks ago

Description: modified (diff)

comment:2 by Sarah Boyce, 6 weeks ago

Triage Stage: UnreviewedAccepted

Thank you Thibaud!

comment:3 by Sarah Sanger, 6 weeks ago

Owner: set to Sarah Sanger
Status: newassigned

comment:4 by Sarah Sanger, 3 weeks ago

Has patch: set
Version 0, edited 3 weeks ago by Sarah Sanger (next)

comment:5 by Sarah Boyce, 3 weeks ago

Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top