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

Support for css variables #3028

Closed
kolaente opened this issue Jul 4, 2020 · 16 comments
Closed

Support for css variables #3028

kolaente opened this issue Jul 4, 2020 · 16 comments

Comments

@kolaente
Copy link

kolaente commented Jul 4, 2020

This is about Bulma.

Overview of the problem

This is about the Bulma CSS framework

Description

I think using css variables in bulma would greatly enhance the framework since they allow things like easier theming with less boilerplate - other more "mainstream" frameworks like bootstrap are also using them.

CSS variables can be considered stable to use since most browsers seem to support them since a while now.

I've looked at #2342 which seems to be related to this but is more precisely about dark themes while I hope this issue is a more general look at css variables in bulma - I wasn't able to find a broader issue about this topic. Please tell me if I should rather close this issue.

@piotrpog
Copy link

piotrpog commented Jul 4, 2020

agreed, nowadays custom property support is must-have.

@jgthms
Copy link
Owner

jgthms commented Jul 5, 2020

It is planned. I have a few branches working on it. I only need to find the best way to implement it. There are a few options.

@kolaente
Copy link
Author

kolaente commented Jul 5, 2020

@jgthms That's great to hear! Anything we could help you with?

@jgthms
Copy link
Owner

jgthms commented Jul 5, 2020

If you could provide an example of how you would use CSS variables, or how you already use them, that would be great.

@kolaente
Copy link
Author

kolaente commented Jul 5, 2020

I would use css variables for theming my application (classic use case would be a light/dark theme). CSS variables let me do stuff like this:

:root, [data-theme="default"] {
  --color-primary: black;
  --color-bg: white;
}

[data-theme="dark"] {
  --color-primary: white;
  --color-bg: black;
}

body {
  background-color: var(--color-bg);
  color: var(--color-contrast-high);
}

That way, when a user changes their theme I (or rather, a js snippet) would add a data-theme="dark" to the <body> element and call it a day.
My main use would be color - maybe bulma doesn't need to convert all less variables to css variables at once.

I know I achieve the same with sass or less but that would require me to have essentially two versions of the whole site stylesheet, which can get quite big.

@jgthms
Copy link
Owner

jgthms commented Jul 5, 2020

Ok great. Your approach is exactly what I do for my own website: https://jgthms.com/

The CSS is built on top of Bulma, which I had to tweak to add the CSS variables. I agree we should focus on colours first. I hope to make it easy to implement a dark mode like this.

@BraydenTW
Copy link

@kolaente, wouldn’t you rather use SASS variables? Those are more popular and easier use than CSS’s variables.

@kolaente
Copy link
Author

kolaente commented Jul 8, 2020

@BraydenTW CSS variables are as easy to use as SASS variables IMHO but SASS variables would require me to ship one full css bundle for each theme whereas I can only change the variables with css variables and have the browser do all the work for me - only requiring me to ship one css bundle.

@BraydenTW
Copy link

Ok no worries then. I completely understand that using SASS would take more work.

@kolaente
Copy link
Author

kolaente commented Jul 9, 2020

@BraydenTW Oh it wouldn't even take more work, it would just mean shipping a css bundle twice the size to my users.

@BraydenTW
Copy link

Oh ok sorry about this. I’m new to the “Bulma party” so it doesn’t make much sense at first.

@kolaente
Copy link
Author

kolaente commented Jul 9, 2020

No worries, and welcome! 🙂

@Tofandel
Copy link

#2981 does. exactly. this.

@kolaente
Copy link
Author

@jgthms Any update on this?

@timetraveler328
Copy link

@jgthms do you have an update on timing for this?

@silverwind
Copy link

This is fixed I guess.

@jgthms jgthms closed this as completed Mar 24, 2024
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

No branches or pull requests

7 participants