rstudio / rstudio/bslib

Vertical alignment of `input_dark_mode()` icon

Open
#822 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
SCSS
Stars
569
Forks
72
Avg merge
1d 2h
Merged PRs (30d)
5

Description

When bringing in the dark mode switch, I noticed that the vertical alignment of the dark mode switch didn't quite line up with other icons. I thought at the time that this was a Bootstrap-specific issue, but after testing in Safari I've realized that it's likely a broader issue we should resolve (my initial testing was in Chrome).

The current state of things is that in input_dark_mode(), I disabled the vertical correction by setting the property to a space. https://github.com/rstudio/bslib/blob/b9ac2cfc0f69e08714648f8263b027fb7e9e8511/R/input-dark-mode.R#L45-L49
Users can still nudge the icon by including an inline style, e.g. style = css("--vertical-correction" = "-5px").

The Build-a-box app is a good example of the dark mode input in action.

However, with the vertical correction disabled, here's the icon appearance (on MacOS for each of these)

Chrome Firefox Safari
image image image

If I activate the original component rules by removing the space-toggle CSS variable from the input element, we get this:

Chrome Firefox Safari
image image image

(Basically they each move down by ~1px when the default vertical correction is used.)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in R/input-dark-mode.R at lines 45-49 and inspect how the --vertical-correction setting affects the input_dark_mode() icon. Compare the icon across Chrome, Firefox, and Safari, using the Build-a-box app as a reference; done means consistent vertical alignment without removing users’ ability to override the correction.

Written by the indexing model from the issue text.

Assessment

Tech stack
bootstrap, r, scss
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.