https://kotlinlang.org logo
#kobweb
Title
# kobweb
a

Alexander Black

09/26/2023, 11:41 PM
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

David Herman

09/26/2023, 11:41 PM
Use an
@InitSilk
block and use
ctx.theme.replaceComponentStyle(...)
a

Alexander Black

09/26/2023, 11:41 PM
@David Herman You’re the best! Thanks man
d

David Herman

09/26/2023, 11:42 PM
You're welcome! There's also
ctx.theme.modifyComponentStyle
if you want to keep the current style but just tweak it
a

Alexander Black

09/26/2023, 11:42 PM
Oh that’s super nice!
as always thanks so much for the quick response. 🙂
d

David Herman

09/26/2023, 11:43 PM
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

Alexander Black

09/26/2023, 11:44 PM
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

David Herman

09/26/2023, 11:47 PM
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

Alexander Black

09/26/2023, 11:48 PM
awesome!!!
definitely don’t mind changing them… in fact that’s what I was trying to do.
d

David Herman

09/26/2023, 11:50 PM
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

Alexander Black

09/26/2023, 11:50 PM
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

David Herman

09/26/2023, 11:51 PM
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

Alexander Black

09/26/2023, 11:52 PM
Not a problem. 🙂
Keep up the good work man.
d

David Herman

09/26/2023, 11:52 PM
Thanks much!
👍 1
9 Views