fix: improve theme select legibility in dark mode on Windows Firefox#3900
fix: improve theme select legibility in dark mode on Windows Firefox#3900dashitongzhi wants to merge 2 commits into
Conversation
Firefox on Windows renders native <select> dropdown option elements with incorrect colors in dark mode — option backgrounds appear white and hovered/checked text is invisible. Add explicit dark-theme color rules for the select and option elements so that backgrounds use the dark surface color and text remains legible. Fixes withastro#3426
✅ Deploy Preview for astro-starlight ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
Hello! Thank you for opening your first PR to Starlight! ✨ Here’s what will happen next:
|
There was a problem hiding this comment.
Pull request overview
Improves the legibility of Starlight’s theme (and other Select.astro-based) dropdown options in dark mode on Windows Firefox by applying explicit dark-theme colors to the native <select> and its <option> states.
Changes:
- Add dark-mode-specific background/text colors for
select,option, andoption:checked. - Add a dark-mode hover style for
option:hoverto avoid white-on-white states in Firefox on Windows.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| :global([data-theme='dark']) select, | ||
| :global([data-theme='dark']) select option, | ||
| :global([data-theme='dark']) select option:checked { | ||
| background-color: var(--sl-color-gray-6); |
HiDeoo
left a comment
There was a problem hiding this comment.
Thanks for the contribution 🙌
If I'm not missing anything, the suggested solution hit the limitation described in this comment, or this one where I link to the exact Firefox bug, which prevent Starlight itself from setting a solid background colour, which may or may not match the nav bar.
For example, the homepage of the deploy preview of the PR now renders as such on Chrome:
Let me know if I'm missing something.
Fix: Scope dark mode select fix to Firefox onlyHiDeoo, thanks for the review! You're right — the fix was too broad. Changes made:
The dropdown options will still have proper dark backgrounds in Firefox, but the select element itself stays transparent — so the homepage hero nav bar looks correct in all browsers. |
… background Address review feedback from HiDeoo: - Use @supports (-moz-appearance: none) to target Firefox only - Only fix option backgrounds, not the select element itself - Use --sl-color-bg-nav instead of --sl-color-gray-6
|
Thanks for the update. As I mentioned in this comment, I was personally never able to reproduce the issue on Windows at the time. Before potentially discussing this new approach further and its potential drawbacks, I would like to make sure it's still an issue or the issue didn't change. I'm mentioning this because I just tested to reproduce again now on a Windows machine, and while I still can't reproduce the issue, I did notice on the latest Firefox version, the dropdown menu now renders differently from the previous screenshots I shared here. Now, in dark mode, the dropdown background is the expected color and no longer white which was not the case before. Would you be able to share the Firefox version you're currently using for testing, and if not the latest, could you try updating and testing the default version (e.g. on https://starlight.astro.build/ and not this PR) and share a new screenshot to see if it matches what I'm seeing? I know it's a bit annoying but issues that we can't easily reproduce or don't know all the requirements to reproduce can be very difficult to fix, and need extra care. |

Description
Fixes the theme select dropdown having illegible colors in dark mode on Windows Firefox.
On Windows, Firefox renders native
<select>dropdown options with white backgrounds in dark mode, making the text nearly invisible. The hovered/checked option text color is also white-on-white.Before
The theme select in dark mode on Windows Firefox shows white option backgrounds with poor contrast, making it hard to read available options.
After
Explicit dark-theme color rules are applied to the select and option elements, using the existing Starlight design tokens (
--sl-color-gray-6,--sl-color-text,--sl-color-accent-high,--sl-color-text-invert).Changes
select,option, andoption:checkedinSelect.astroFixes #3426