Inject Stylus into shadowRoots

inject styles of stylus-addon in shadowRoot

目前為 2025-06-29 提交的版本,檢視 最新版本

作者
hdyzen
評價
0 0 0
版本
1.1
建立日期
2025-06-29
更新日期
2025-06-29
尺寸
1.6 KB
授權條款
GPL-3.0-only
腳本執行於
所有網站

Inject Stylus into shadowRoots

This userscript injects styles from the Stylus extension directly into shadowRoot instances, allowing you to style the content of web components.


How to style content inside a shadowRoot

:host

To apply styles only to the content within a shadowRoot, use the :host pseudo-selector in your Stylus styles. :host refers to the element that contains the shadowRoot (the shadow host).

/* All elements */
* {
  border: 1px violet;
}
/* Only elements inside the shadowRoot */
:host * {
  border: 1px solid mediumpurple;
}

Similar forms: