psyche icon indicating copy to clipboard operation
psyche copied to clipboard

Custom styling

Open oscarotero opened this issue 2 years ago • 4 comments

Hi. As I can see, this component use a style tag in the shadow root to apply styles and use themes to apply colors and fonts. I recommend to use CSS ::part() pseudo selector for more flexibility and maintainability.

You can see an example of this in the oom-components/searcher web component:

  • The customizable elements in the Shadow DOM are labeled with the part attribute: https://github.com/oom-components/searcher/blob/main/searcher.js#L37
  • And with simple CSS, you can customize the appearance of the element even in different states like :hover, :focus, :disabled etc: https://github.com/oom-components/searcher/blob/main/demo/styles.css#L9-L16

This would make more easy to apply styles on different media queries, light/dark themes, etc. For example:

psyche-search::part(input) {
    border-color: var(--primary-color);
}

And it allows to combine a base theme in the shadow DOM that can be overrided by outside css.

oscarotero avatar Jan 27 '22 19:01 oscarotero