0

I have a web component my-icon. The component wraps an icon-font and some "business related" ui-logic to choose the correct icon by the given name:

<my-icon name="arrow-left" />

The user can also decide which size and color the icon should have. What is the right way to provide this functionality?

  • Custom styles --my-icon-color and --my-icon-size
  • Properties + Attributes for color and size
  • Both

Currently I provide both, but I'm not sure if it's a good practice to "style" a component via attributes and properties. On the other hand it may ease the use of the component (e.g. change the color via Data-Binding).

Thank you

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Meisenmann
  • 119
  • 8

1 Answers1

0

There is no best practice, there are multiple ways to style shadowDOM, which one you use is up to you.

ShadowDOM is styled by:

Danny '365CSI' Engelman
  • 16,526
  • 2
  • 32
  • 49
  • Thank you for your answer. But i was rather looking for a best practice to provide a styling API for the users of my component. – Meisenmann Mar 03 '22 at 05:54