Loading State
Show a loading animation while the SDK starts.
States
A placement has three states. The SDK controls them.
loading
A loading animation
From first paint until the first render() finishes
rendered
The offer panel
After a successful render()
error
Nothing. The panel is hidden.
When the SDK cannot render. The error event fires.
The host element carries the state in the data-cg-elements-state attribute.
Add the loader
Import the loader stylesheet in your bundle.
import '@covergenius/elements/loader.css';The stylesheet shows the animation in two cases:
Your HTML has
<cg-elements>but the SDK script has not run yet.The SDK is ready but
render()has not finished.
The stylesheet reserves 20rem of height. This prevents the page from jumping when the panel appears.
Use the loader with no extra request
Copy the rule from loader.css into an inline <style> block in your page head. The animation is part of the rule, so no file loads.
Change the loader
The loader does not read theme values. It uses a fixed Cover Genius color so that it works before the theme loads. To change it, write your own CSS for these selectors:
Last updated
Was this helpful?

