In the silk library how can I override default com...
# kobweb
a
In the silk library how can I override default component styles? or set new default component styles? For example how can I override the Divider color?
d
Use an
@InitSilk
block and use
ctx.theme.replaceComponentStyle(...)
a
@David Herman You’re the best! Thanks man
d
You're welcome! There's also
ctx.theme.modifyComponentStyle
if you want to keep the current style but just tweak it
a
Oh that’s super nice!
as always thanks so much for the quick response. 🙂
d
If you look at the source, you'll also see `StyleVariable`s that the widgets depend on, and you can set those directly as well, although that may be a more advanced trick 🙂
🙌 1
You're welcome. I'm not always around but when I am happy to respond quickly 🙂
a
Very much appreciate it man. Generally figuring out your framework has been intuitive and fun.
Nice to have you around though for the few times I get stuck. 😄
d
Oh yeah I forgot, one final thing to be aware of is you can change palette values sometimes (although heads up that code is about to change in 0.14.1 so be prepared for a possible compile errors around modifying palettes). Divider depends on the border color, so if you don't mind changing borders across all widgets, that would be:
Copy code
ctx.theme.palettes.light.border = Colors.DarkGray
ctx.theme.palettes.dark.border = Colors.LightGray
or whatever
🙌 1
a
awesome!!!
definitely don’t mind changing them… in fact that’s what I was trying to do.
d
Glad it's been generally intuitive for you! And really glad to hear it's been fun (I think so too!) There's still a lot I need to put down into docs or guides and probably sooner than later at this point. Kobweb is asking a lot (CSS, JS APIs, Compose concepts....) even before you start worrying about Silk and Kobweb-specific questions.
a
and thanks for the heads up regarding the change coming. 🙂 Not a problem. I’m used to adapting projects to new API changes.
Ya more docs would be cool, but like I’ve said before… generally having more extensive example apps is good enough for me in most cases.
d
Thanks. It shouldn't be too crazy. The same code I put above should work except you'll need to import
border
because it's going to become an extension property (Silk is getting refactored and part of that is palette is becoming a more general, extensible concept)
👍 1
Yeah, more example apps too 🙂
a
Not a problem. 🙂
Keep up the good work man.
d
Thanks much!
👍 1