Imported components support standard React styling approaches, but with important considerations for Shadow DOM isolation.
Code components render in Shadow DOM, which creates an isolated styling boundary. This means:
Rendering components in Shadow DOM prevents style conflicts to ensure your component looks and behaves as expected. However, this also means you need to explicitly connect to external styles like site variables, inherited properties, or tag selectors.
To ensure your code components are styled correctly, you can import your styles directly into your *.webflow.tsx file.
If you want to apply styles across all components, you can import your styles into a global decorators file.
Then reference it in your webflow.json. Once applied, all components will inherit the styles from the global css file.
The following table shows which CSS features work within Shadow DOM:
Reference a site’s variables in your components:
To get the exact variable name, click “Copy CSS” in the three-dot menu next to any variable in the Variables panel.
CSS properties set to inherit work across Shadow DOM boundaries. Your component inherits styles from the parent HTML element:
For example, if your component is placed inside a <div> with font-family: sans-serif, setting font-family: inherit in your component will use sans-serif.
Tag selectors (like h1, p, button) defined in your site’s CSS can be automatically applied to your component. Enable this with the applyTagSelectors option in your component definition file.
Code components support modern CSS frameworks and libraries, but some require specific configuration for Shadow DOM compatibility. For guidance on using CSS frameworks and component libraries with code components, see the frameworks and libraries guide.