Enable theming / custom styling#1
Conversation
|
@dzole0311 tagged you in the PR, but while editing the comment, so not sure you'd have got a notification, tagging you again just in case :) (and to emphasize how desperate I am to get another set of 👀 and someone to talk to about this haha ) |
|
@batpad I think this is already moving in a good direction. One possible approach we could let guide this work is design-token based theming for the widgets and static exports. I think Radix is a good example for this, it exposes a small-ish theme config and shared tokens but also discourages really heavy overriding of styles per-component. If someone needs lots of overrides ideally they would use tokens, props/variants or they just build a more custom component from lower-level component primitives. For Also, have you considered making the default |
|
Wow, thanks much for the thoughtful notes @dzole0311 Yes, I think the key is to look at the JupyterLab theming (did not know about the I don't think there's any rush to merge this - I think I mostly just wanted to get a good sense of what possibilities are here and how one would architect this in a hypothetical future. If you ever want to take this for a ride and implement some ideas, please go ahead. I think I'll deprioritize this until we have a real use-case - though I think it is really cool to allow custom theming, so would definitely like to think this through a bit properly and do at some point. This is definitely one of those things I want to think through and not rush though, and all your comments make a lot of sense - thanks much 🙏 |
Just leaving as a draft to think about how one might enable custom styling of widgets and having "themes".
Goal: Users should have some way to customize styling of widgets: at least things like colours, fonts and some sizing / spacing.
Here, we specify a bunch of CSS variables for things like colours, fonts, etc. that are then used consistently across widgets. We then allow these to be over-ridden either on a per-widget, per-property basis or by creating a theme object to apply a bunch of over-rides consistently.
So, you can create a theme like:
And then, pass this
themeobject to widgets to set the theme accordingly. This requires us to define a set of CSS variables, and then use them consistently across widgets.While I like the usage ergonomics and this seems all nice, there's a few problems that I want to think through before blindly merging:
I was really keen on figuring out some solution / pathway to a solution so users have some flexibility with styling of widgets - I find it really frustrating when I have to use a widget that I can't customize styling of at all to fit my needs. It's possible that the better solution for now is a bit of a lower level interface, allowing to over-ride a Style object or so, instead of trying to abstract this with themes and force all widgets to use common CSS variables.
Definitely need to think about this a bit, but thought it useful to put up a sketch - this PR does work and allow theming, but does also introduce a lot of complexity.
@dzole0311 if you are getting into this, I'd really appreciate your thoughts if you're able to give this a quick skim to get an idea of the implementation and we can discuss approaches.