Skip to content

Fixed #2557 -- Improved color contrast for the Django logo focus indicator#2558

Merged
SaptakS merged 2 commits intodjango:mainfrom
bryan-oginga:fix/dark-mode-logo-focus-indicator
Apr 13, 2026
Merged

Fixed #2557 -- Improved color contrast for the Django logo focus indicator#2558
SaptakS merged 2 commits intodjango:mainfrom
bryan-oginga:fix/dark-mode-logo-focus-indicator

Conversation

@bryan-oginga
Copy link
Copy Markdown
Contributor

In dark mode, the Django logo focus indicator used var(--menu)
which renders as black against the dark green footer background,
making it nearly invisible and failing accessibility contrast requirements.

Changed to var(--body-fg) which renders as #C1CAD2 (light gray)
in dark mode, matching other focus indicators on the page and
providing sufficient contrast.

Copy link
Copy Markdown
Contributor

@erosselli erosselli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Thanks for contributing! I don't think this quite fixes the issue, the updates are for the logo on the footer (which is already OK since it was fixed in PR #2540) but the issue is asking for changes on the logo for the main navbar

Comment on lines -1015 to 1016
outline: 2px solid var(--menu);
outline: 2px solid var(--body-fg);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the logo within the footer, which already has the white focus indicator and it's visible (see how it's nested under the .footer class) . The ticket is talking about the logo on the main navabar at the top left of the page

Django logo at the top of the page with a black focus indicator, low contrast

@bryan-oginga
Copy link
Copy Markdown
Contributor Author

Hello Eli,I have updated the fix, logo focus outline is now white in both light and dark mode.

Before

image

After

image

Copy link
Copy Markdown
Contributor

@erosselli erosselli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! I left some comments.

Let's also make sure the PR title follows our commit guidelines , and contains info about the problem/fix (e.g "Fixed #2557 -- Improved color contrast for the Django logo focus indicator.") rather than its specific implementation ("Use --body-fg variable ...")

Comment thread djangoproject/scss/_dark-mode.scss Outdated
}
}

/* Fix logo focus outline in dark mode - header is always dark green */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this comment is really helping anything, we should probably remove it

Comment thread djangoproject/scss/_dark-mode.scss Outdated
Comment on lines +363 to +373
html[data-theme="dark"] header .logo:focus {
outline: 2px solid #ffffff !important;
outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
html:not([data-theme="light"]) header .logo:focus {
outline: 2px solid #ffffff !important;
outline-offset: 2px;
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more generally, I don't think these changes are needed. If something needs a lot of !important statements that's usually a sign that we're not coding our CSS in the best way

Comment on lines +507 to +510
&:focus {
outline: 2px solid var(--white-color) !important;
outline-offset: 2px;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should be able to reduce this down to , that's what we have in the footer and it's working fine.

&:focus {
            outline: 2px solid var(--menu);
        }

Can you explain why you added the outline-offset here? I don't think we have that offset in our other focus indicators

Comment thread djangoproject/scss/_style.scss Outdated
Comment on lines +1018 to +1019
&:focus {
outline: 2px solid var(--menu);
outline: 2px solid var(--body-fg);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an unrelated change and not needed, please undo it -- the footer focus indicator already works as expected

@bryan-oginga bryan-oginga changed the title Fixed #2557 -- Use --body-fg variable for logo focus indicator in dark mode Fixed #2557 -- Improved color contrast for the Django logo focus indicator Mar 30, 2026
@bryan-oginga bryan-oginga force-pushed the fix/dark-mode-logo-focus-indicator branch from 5fbb9b2 to 6470f4f Compare March 30, 2026 05:42
@bryan-oginga
Copy link
Copy Markdown
Contributor Author

Thanks Eli for your review! I've addressed all the comments and reverted the unrelated footer change

@bryan-oginga bryan-oginga force-pushed the fix/dark-mode-logo-focus-indicator branch 2 times, most recently from 6c38c64 to 16649a8 Compare April 10, 2026 10:56
Copy link
Copy Markdown
Contributor

@erosselli erosselli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Thanks for contributing :) I tested it and the focus indicator is white in both dark and light mode.
Screenshot of the dark mode Django logo focus indicator, which is white

@SaptakS SaptakS merged commit 858167b into django:main Apr 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

3 participants