> For the complete documentation index, see [llms.txt](https://partner-docs.covergenius.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://partner-docs.covergenius.com/elements/guides/loading-state.md).

# Loading State

Show a loading animation while the SDK starts.

### States

A placement has three states. The SDK controls them.

| State      | What the customer sees        | When                                                 |
| ---------- | ----------------------------- | ---------------------------------------------------- |
| `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.

```js
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:

```css
cg-elements:not(:defined),
cg-elements[data-cg-elements-state='loading'] {
  /* your styles */
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://partner-docs.covergenius.com/elements/guides/loading-state.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
