> For the complete documentation index, see [llms.txt](https://highfivethemes.gitbook.io/the-reporter-user-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://highfivethemes.gitbook.io/the-reporter-user-documentation/custom-widget-html-widget.md).

# Custom Widget (HTML Widget)

**The Reporter** supports adding custom **HTML Widget**. That custom widget will show up  inside sidebar on Posts with sidebar pages.&#x20;

### To add **Custom Widget:**

1. Go to **Settings > Design & branding** from the admin menu and click <mark style="color:green;">**Customize**</mark>
2. Click **Site-wide** in the **Design** settings sidebar on the right
3. Find **HTML WIDGET** text input
4. **Paste** <mark style="color:green;">**HTML**</mark> **code**, prepared for your widget and click **Save**
5. **To add&#x20;**<mark style="color:green;">**CSS**</mark>**-styles,** go to **Settings** > **Code Injection**&#x20;
6. **Paste** your <mark style="color:green;">**CSS**</mark> code inside **Site header** text input (Your **CSS** code should be inside [**HTML tag \<style>\</style>**](https://www.w3schools.com/tags/tag_style.asp))

   <figure><img src="/files/klV8Us1uU3gFcolkdxjU" alt=""><figcaption></figcaption></figure>
7. **To add&#x20;**<mark style="color:orange;">**JavaScript**</mark>**&#x20;code,** go to **Settings** > **Code Injection**
8. **Paste** your <mark style="color:orange;">**JavaScript**</mark> code inside **Site footer** text input (Your **JavaScript** code should be inside [**HTML tag \<script>\</script>**](https://www.w3schools.com/tags/tag_script.asp))&#x20;

   <figure><img src="/files/8py1MWxNfAcUlnR1sYYE" alt=""><figcaption></figcaption></figure>

## TO ADD 'STICKY' EFFECT:

To add "sticky" effect to this widget (so It will stick to the screen when you will scroll page down) you can take this **CSS** and **Javascript** code:

#### CSS:

```css
.gh-sidebar-custom-widget {
    position: sticky;
    animation: fadeIn 1s ease-in-out;
    transition: top 0.45s ease;
}
.gh-sidebar-custom-widget.with-big-header {
    top: 152px;
}
.gh-sidebar-custom-widget.with-small-header {
    top: 60px;
}
.gh-sidebar-custom-widget.moved {
    top: 32px;
}
```

#### JavaScript:

```javascript
const moveWidget = () => {
  const widget = document.querySelector('#sidebar-custom-widget');
  let lastScrollTop = 0;

  const widgetScrollHandler = () => {
    const scrollTop = window.scrollY;
    const windowWidth = window.innerWidth;
  
    if (windowWidth > 1100) {
      if (scrollTop > 200) {
        if (scrollTop > lastScrollTop) {
          widget.classList.add('moved');
        } else {
          widget.classList.remove('moved');
        }
      }
  
      lastScrollTop = scrollTop;
    }
  };

  if (widget) {
    window.addEventListener('scroll', widgetScrollHandler);
  }
};

moveWidget();
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://highfivethemes.gitbook.io/the-reporter-user-documentation/custom-widget-html-widget.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
