Common way to declare configurable styles in web components #5816
Replies: 3 comments 2 replies
-
IMO option 1 & 3 may be harder to override, but they are well scoped, while version to is leaky and could cause unwanted side effects and also produce naming conflicts. I'm voting for |
Beta Was this translation helpful? Give feedback.
-
Option 1 is a more complicated way of writing option 2. Otherwise I'd agree with Oli. Sometimes it's handy to have access to a whole element (e.g. dropdown arrow to be able to set size, background, position, animation etc. in one go), sometimes a simple property tweaking is enough. Documenting the two options appropriately is key. |
Beta Was this translation helpful? Give feedback.
-
I agree that CSS variables and parts can be useful for different situations, and both could help us. But they also let users change our components, which might cause inconsistencies with our design language. So, I think it’s important to clearly state how and when to use them, depending on what we want to allow or prevent. For example, we recently got a message in our support channel where a user wanted to change the accordion styles using a CSS part that was originally made to simplify internal styling: https://teams.microsoft.com/l/message/19:[email protected]/1752758349749?tenantId=3ae7c479-0cf1-47f4-8f84-929f364eff67&groupId=123c7c9e-052a-40e6-98d3-6cc6d46bad0a&parentMessageId=1752736838706&teamName=Design%20System&channelName=%F0%9F%9A%91%20Support&createdTime=1752758349749 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Option 1: Define CSS custom properties on the host
post-component
styles:Usage in other components:
Option 2: Use a
var()
with a fallbackpost-component
styles:Usage in other components:
Option 3: Use parts
post-component
renderer:post-component
styles:Usage in other components:
Please add your comments or vote by reacting to the discussion with:
Beta Was this translation helpful? Give feedback.
All reactions