Implement dark mode for rustup.rs website#4729
Conversation
so that it's eaiser to write dark mode.
the black logo is almost invisible in dark mode. following the approach from rust-lang/blog.rust-lang.org@614b18b.
@Bogay Good idea! Lemme have a test locally and get back to you later, please be patient 🙏
I believe they are not "dead code" per se but rather reserved for future use, see below for an usage example :) Line 45 in a373a2c ... the visibility is controlled either by your host platform, or by typing |
There was a problem hiding this comment.
Can we make the copy button dark mode-aware as well? Something among the lines of...
...
#platform-instructions-unknown button.copy-button {
...
background-color: var(--code-shadow-color);
color: var(--copy-button-text-color);
}
div.copy-icon {
...
}
div.copy-icon svg {
fill: var(--body-color)
}PS: Sorry if I misused your palette, I'm not super good at this 🙏
Otherwise, LGTM!
This comment has been minimized.
This comment has been minimized.
@Bogay Looks cool, thanks!
Sure, that's a good idea :) |
6f2df37 to
1771ea2
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
use class instead of multiple id selector.
1771ea2 to
d6ca3b2
Compare
|
I've updated the css selectors. Maybe it's ready to merge now? |






This PR introduces dark mode for rustup.rs website. For simplicity, I haven't added theme-switching logic in javascript. Instead, it relies solely on
@media (prefers-color-scheme: dark)to override css variables for dark mode. The color palette is adapted from the blog's dark mode with a little modification (rust-lang/blog.rust-lang.org#1343).However, I am not sure whther the I should adjust of the copy button. It currently uses the browser's default styles, which makes the "Copied!" feedback text slightly difficult to read in dark mode.
Screenshots
before:
after:
Close #4209