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

Dark mode #117

Closed
PigeardSylvain opened this issue Jan 30, 2019 · 9 comments · Fixed by #2223
Closed

Dark mode #117

PigeardSylvain opened this issue Jan 30, 2019 · 9 comments · Fixed by #2223

Comments

@PigeardSylvain
Copy link
Member

A dark mode is needed for all components.

Stencil
image

@Lausselloic
Copy link
Member

dark mode would quite double the size of css.
We need to define the strategy for that, does all components need to have a dark alternative?

@ffoodd
Copy link
Contributor

ffoodd commented Apr 10, 2019

Using CSS custom properties, this should be quite easy and only cost a new declaration block redefining some variables.

body {
    --background: white;
    --color: black;
}

.component {
    background: var(--background);
    border-color: currentColor;
    color: var(--color);
}

.is-dark {
    --background: black;
    --color: white;
}

By setting main color scheme on body, you get it for free everywhere as a default. And by using a utility class to switch to dark theme, you'll be able to use it on a component, on an entire section, or even directly on body to globally use dark theme.

And being lazy would be good: ensure using currentColor everywhere color code should match font's color. Also keep in mind var() function gets a second argument for default value (could save time).

IMHO this is the best possible approach, but it's highly related to browser support: that means no dark mode for IE11…

@ffoodd
Copy link
Contributor

ffoodd commented Jun 19, 2019

I reply to myself on this: .browserlistrc mentions IE10 and some other browser which don't support CSS custom properties.

Might try the same way using inherit and currentColor keywords, but not quite sure that it would work everywhere…

Is the "for all components" thing serious? If it is, I guess that dark mode should probably not be component specific but application specific: making a whole Boosted dark mode.

I've done this before…

@ffoodd ffoodd added the feature label Dec 4, 2019
@ffoodd ffoodd self-assigned this Jan 13, 2020
@ffoodd ffoodd added this to the 5.0.0 milestone Jan 16, 2020
@ffoodd ffoodd changed the title [Boosted vs Brand stencils] Dark mode Dark mode Jan 16, 2020
@ffoodd
Copy link
Contributor

ffoodd commented Jan 17, 2020

@ffoodd
Copy link
Contributor

ffoodd commented Apr 22, 2020

@PigeardSylvain FWIW, since v5 dropped IE11 support, my suggestion using custom properties should be fine :)

Things that worked in v4:

  • Close button
  • Navbar
  • Buttons (using .btn-inverse)
  • Alerts (only links need to adapt, could be done globally)
  • etc.

@ffoodd ffoodd mentioned this issue Apr 22, 2020
26 tasks
@ffoodd ffoodd added the bootstrap-side Things to implement in Bootstrap first label Oct 19, 2020
@ffoodd
Copy link
Contributor

ffoodd commented Jan 22, 2021

Discussions in Bootstrap are taking place in #27514 with an interesting suggestion by mdo.

This was referenced Jan 27, 2021
@ffoodd
Copy link
Contributor

ffoodd commented Feb 18, 2021

Bootstrap added dark variants to some components, noticeably carousel and dropdown. Don't think it's a safe way to, though.

@MewenLeHo
Copy link
Contributor

Some useful ressources about the prefers-color-scheme media query:
https://opensource.com/article/21/10/dark-themes-websites
https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme

@ffoodd
Copy link
Contributor

ffoodd commented Nov 2, 2021

This should not be handled as a user preference since it's a branding choice. Supporting user choice is a great idea but dark mode (in that case) is not about users.

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

Successfully merging a pull request may close this issue.

5 participants