Use CSS Variables
Web Components ⟩ Shadow DOM ⟩ Styling ⟩
Google ⟩ Web Component ⟩ Creating style hooks using CSS 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;
}Last updated
Was this helpful?