Component decorators
This update introduces component decorators, a new pattern for applying global styles and wrapping components with providers. Configure globally to apply to every component in your library or locally to a single component.
Packages:
@webflow/webflow-cli1.9.0@webflow/react1.1.0@webflow/data-types1.1.0@webflow/emotion-utils1.1.0@webflow/styled-components-utils1.1.0
Global component decorators
Instead of importing styles or adding decorators to each component individually, you can now configure them once in a global decorators file.
Configure in webflow.json:
Global styles
Import CSS once and apply it to all components:
CSS-in-JS libraries
For Emotion and styled-components, export the pre-built decorators to inject styles into the Shadow DOM:
Pre-built decorators:
emotionShadowDomDecoratorfrom@webflow/emotion-utilsstyledComponentsShadowDomDecoratorfrom@webflow/styled-components-utils
See more on pre-built decorators in the frameworks and libraries guide.
Custom decorators
Create custom decorators for error handling, analytics, or other cross-cutting concerns:
Apply decorators to a single component
To apply decorators to a single component, add a decorators property to the declareComponent configuration object.
Learn more in the component decorators documentation.