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

Remove uppercase transformation from sidebar tab items for accessibility reasons #2043

Conversation

hichemfantar
Copy link
Contributor

@hichemfantar hichemfantar commented Jan 20, 2025

Improved readability by removing the uppercase transformation from sidebar list items.

this solution even saves horizontal space

Important for accessibility

research:
https://www.a11y-101.com/design/capitalisation

https://accessibility.huit.harvard.edu/design-readability

Avoid using all caps. Readability is reduced with all caps because all words have a uniform rectangular shape, meaning readers can't identify words by their shape.

tldr: The best thing to do is to avoid uppercase letters

before
image

after
image

@hichemfantar hichemfantar changed the title Remove uppercase transformation from sidebar list items Remove uppercase transformation from sidebar list items for accessibility reasons Jan 20, 2025
Copy link

@hichemfantar hichemfantar marked this pull request as ready for review January 20, 2025 17:47
@hichemfantar hichemfantar changed the title Remove uppercase transformation from sidebar list items for accessibility reasons Remove uppercase transformation from sidebar tab items for accessibility reasons Jan 20, 2025
@josevalim
Copy link
Member

After rebasing this pull request with some other changes, I think the menu is not calling enough attention to it, especially the currently selected item:

Screenshot 2025-01-21 at 20 36 27

I think we may need other changes to either the selected one or all of them, to make them standout more.

@josevalim
Copy link
Member

josevalim commented Jan 21, 2025

FWIW, the vitepress plugin makes the font a bit darker, docusaurus changes the color of the selected item. We probably want to apply this here and to our regular tabsets. Another option is to bold the currently selected item.

@hichemfantar
Copy link
Contributor Author

hichemfantar commented Jan 21, 2025

the menu doesn't call attention because it previously relied on uppercase to make up for the thin font (still bad in terms of a11y), but now without uppercase we need to bring back the font to a normal level so it looks visible enough

example

image

@hichemfantar
Copy link
Contributor Author

hichemfantar commented Jan 21, 2025

also notice how vite and the new font weight are pretty much identical (further proof (besides the research i linked) it's the more correct weight to use because vitepress has a large team behind with lots of experience in building great web experiences)

image

image

@josevalim
Copy link
Member

I tried the increased font-weight locally to all of them and I thought it was still too subtle. :( You can see in the image above vitepress is also changing other styles besides of only the border.

@hichemfantar
Copy link
Contributor Author

i suppose we could slightly lower the opacity of inactive elements but that would be horrible for readability if we keep the light font.

@josevalim
Copy link
Member

I agree. I will play with some ideas too. WDYT about bolding the current selection? I want to avoid changing the font color though, because that changes per theme and language, and it will be hard to guarantee all languages look good across all themes.

@hichemfantar
Copy link
Contributor Author

bolding the current selection would cause a slight layout shift when changing selection and the light weight font would still be an issue since the recommended value is 500 which is the same in all documentation engines i've worked with

@josevalim
Copy link
Member

Good point on bolding and there is no need to repeat the information we are discussing in the other issue, I am aware.

In any case, if we cannot make the tabs look better in isolation, then we may need to look for other approaches.

@hichemfantar
Copy link
Contributor Author

i repeated the info for other participants in the other issue to be aware because it's related to the font issue

@hichemfantar
Copy link
Contributor Author

Although i find the current implementation to be good enough in terms of visibility we could go with this approach which addresses the accessibility issues while calling the attention you feel is missing

image

@josevalim
Copy link
Member

My recommendation for the tabs is to apply some font-color modification, similar to vitepress and docusaurus. Here is how it would like with the Nunito font of #2053 without changing the uppercase:

Screenshot 2025-01-22 at 17 10 50

We could also apply it to the regular tabs too. Thoughts @hichemfantar?

@josevalim
Copy link
Member

It is very subtle, but enough to improve the experience when showing what is selected and also on mouse hover.

@josevalim
Copy link
Member

For regular tabs:

Screenshot 2025-01-22 at 17 14 39

@josevalim
Copy link
Member

We don't plan more changes here, thank you, but I did add some color contrast to active/hover tabsets to main.

@josevalim josevalim closed this Jan 22, 2025
@hichemfantar
Copy link
Contributor Author

@josevalim this is an accessibility fix not aesthetic

@hichemfantar
Copy link
Contributor Author

@josevalim I hope you reconsider and apply the reasoning shown here #2046 (comment) and not look at it from an aesthetic pov

@josevalim
Copy link
Member

I did some research and it was clear that the biggest concern applies to long sequences of uppercase text and not using text-transform.

I am open to alterntives here but this changes makes it so the tabs are not visually distinct enough from the rest of the sidebar. It just feels like regular text.

@josevalim
Copy link
Member

@hichemfantar
Copy link
Contributor Author

Personally the uppercase severely hinders my ability to comfortably read the tab titles, do you experience this or is it the same as lowercase text to you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants