Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style scrollbars for Webkit browsers #525

Merged
merged 2 commits into from May 16, 2024
Merged

Conversation

FireIsGood
Copy link
Contributor

Adds scrollbar colors and styles them to match the site a little better.

Currently, the scrollbars do not match the theme on webkit based browsers (chrome, edge, etc.). This does not affect browsers which do not use webkit (e.g. firefox) as they handle scrollbars differently. This pull request adds styles to them for users with a pointer and just corrects the color-scheme for everyone else.

The changes are made through Tailwind via the @apply property, so no magic numbers.

Before:

Dark Light
dark mode light mode
dark mode light mode

After:

Dark Light
dark mode light mode
dark mode light mode

Concerns

This change modifies the size of the scrollbar which could possibly be an accessibility concern. It is possible to remove the extra styles and just keep the color-scheme if that is the case.

When customizing scrollbars, ensure that the thumb and track have enough contrast with the surrounding background. Also ensure that the scrollbar hit area is large enough for people who use touch input.
MDN

Another concern is the use of .dark to hook into dark mode. The current tailwind settings set the dark mode to be set with a class, but this could theoretically be changed, leading to this breaking. This specific scenario is unlikely as the 'media' option also breaks the theme switcher, but it is technically one possible issue.

Possible Other Solutions

This change works on the scrollbars by styling them directly. It is also possible to just use the color-scheme property on the HTML element when there is the .dark class. This would address the issue of the changed size.

I have separated the dark mode scrollbar colors and the styled scrollbars into separate commits, so feel free to revert the style scrollbars commit if this seems to be the better solution.

Here is what that would result in:

horizontal scrollbars

vertical scrollbars

Adds the color-scheme correctly
Styles scrollbars for users with mouses who are on webkit browsers
@Fechin Fechin merged commit 11fe3a2 into Fechin:main May 16, 2024
@FireIsGood FireIsGood deleted the style-scrollbars branch May 16, 2024 05:40
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.

None yet

2 participants