Last updated 3 years ago
Was this helpful?
Web Components โฉ Shadow DOM โฉ Styling โฉ
Google โฉ Web Component โฉ Creating style hooks using CSS custom properties
CSS Variables
โญ๏ธ use CSS variables: CSS variables exist on all levels, both in light and shadow. ๐ JS.info โฉ CSS hooks with custom properties
<style> fancy-tabs { margin-bottom: 32px; --fancy-tabs-bg: black; <!-- โญ๏ธ css var --> } </style> <fancy-tabs background>...</fancy-tabs>
/* inside shadow DOM */ :host([background]) { background: var(--fancy-tabs-bg, #9E9E9E); /* โญ๏ธ css hook */ border-radius: 10px; padding: 10px; }