Skip to content

Implement dark mode for rustup.rs website#4729

Merged
rami3l merged 6 commits intorust-lang:mainfrom
Bogay:feat/website-dark-mode
Feb 28, 2026
Merged

Implement dark mode for rustup.rs website#4729
rami3l merged 6 commits intorust-lang:mainfrom
Bogay:feat/website-dark-mode

Conversation

@Bogay
Copy link
Copy Markdown
Contributor

@Bogay Bogay commented Feb 26, 2026

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:

image image

after:

image image

Close #4209

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.
Copy link
Copy Markdown
Member

@rami3l rami3l left a comment

Choose a reason for hiding this comment

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

Thanks a lot! Not using JavaScript is also what I'd prefer with the problem you are trying to resolve. Please feel free to adjust the remaining elements with the light theme background :)

View changes since this review

@Bogay
Copy link
Copy Markdown
Contributor Author

Bogay commented Feb 27, 2026

I've moved the "Copied!" text out of the button so that it displays over body background like other link text. I think this make it a little more readable. BTW, I found that #platform-xxx-yyy selectors in rustup.css seems to be unused. Should I remove them?

light:

image

dark:

image

@rami3l
Copy link
Copy Markdown
Member

rami3l commented Feb 27, 2026

I've moved the "Copied!" text out of the button so that it displays over body background like other link text. I think this make it a little more readable.

@Bogay Good idea! Lemme have a test locally and get back to you later, please be patient 🙏

BTW, I found that #platform-xxx-yyy selectors in rustup.css seems to be unused. Should I remove them?

I believe they are not "dead code" per se but rather reserved for future use, see below for an usage example :)

<div id="platform-instructions-win32" class="instructions display-none">

... the visibility is controlled either by your host platform, or by typing test and clicking n.

Copy link
Copy Markdown
Member

@rami3l rami3l left a comment

Choose a reason for hiding this comment

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

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!

View changes since this review

@Bogay
Copy link
Copy Markdown
Contributor Author

Bogay commented Feb 28, 2026

Can we make the copy button dark mode-aware as well?

Sure, but it seems that setting background color remove the hover effect. I've added a simple hover effect on it. The icon become teal when hover. Let me know if you have other concerns.

light:

normal hover
light image image
dark image image

I believe they are not "dead code" per se but rather reserved for future use, see below for an usage example :)

Thanks for the clarification! To clarify, I didn't intend to remove those IDs from index.html. My intention was to simplify the CSS selectors. Since the elements with the platform-instruction-* IDs already have the instructions class, we can just use that class to select them instead.

@rustbot

This comment has been minimized.

@rami3l
Copy link
Copy Markdown
Member

rami3l commented Feb 28, 2026

I've added a simple hover effect on it. The icon become teal when hover.

@Bogay Looks cool, thanks!

My intention was to simplify the CSS selectors. Since the elements with the platform-instruction-* IDs already have the instructions class, we can just use that class to select them instead.

Sure, that's a good idea :)

@Bogay Bogay force-pushed the feat/website-dark-mode branch from 6f2df37 to 1771ea2 Compare February 28, 2026 13:02
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Feb 28, 2026

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.
@Bogay Bogay force-pushed the feat/website-dark-mode branch from 1771ea2 to d6ca3b2 Compare February 28, 2026 13:04
@Bogay
Copy link
Copy Markdown
Contributor Author

Bogay commented Feb 28, 2026

I've updated the css selectors. Maybe it's ready to merge now?

@rami3l rami3l added this pull request to the merge queue Feb 28, 2026
Merged via the queue into rust-lang:main with commit fe5e3b0 Feb 28, 2026
29 checks passed
@rami3l rami3l added this to the 1.29.0 milestone Feb 28, 2026
@Bogay Bogay deleted the feat/website-dark-mode branch February 28, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

color-scheme support for rustup.rs

3 participants