Skip to content

Scroll Y Offset when scrolling to element #990

Open

Description

@ImperviousPanda

Hello, I am just starting to use rapidoc with our APIs and I am trying to add it as a page inside of our website.

Unfortunately this website has a floating scrollbar. So when a user clicks on an endpoint and rapidoc scrolls to the top of that element, the floating header is covering the element. I think what I need is a feature similar to the redoc's 'scroll-y-offset'. So when it does scroll to an element it adds an amount to that scroll position.

Does this feature exist in Rapidoc? Or is there another/better way to do this?

I saw in other git issues the suggestion is to add padding to the parent div of the redoc web element. I am doing this so that the documentation isn't covered by the header, but it still scrolls to the same place. Maybe I am doing this wrong?

Using it in React:

          <div style={{paddingTop: "150px", background: "black" }}>
            <rapi-doc
              spec-url="https://myradar-public-open-api.s3.amazonaws.com/openapi-joined.yaml"
              theme = "dark"
              primary-color = "#8d56ff"
              show-header = "false"
              font-size = "large"
              api-key-name = "Subscription-Key"
              api-key-value = "feef5fc1acfd45c8b59359c15a6622a2"
              api-key-location = "header"
              update-route = "false"
            ></rapi-doc>
          </div>
          ```

Thank you for your time!

Activity

  1. preston-56 commented on Jul 8, 2025

    @preston-56

    @ImperviousPanda was it ever fixed? I'm reproducing the same blocker

  2. preston-56 commented on Jul 8, 2025

    @preston-56

    @ImperviousPanda

    Took me a while, but this came through as a hack that worked consistently for me.

    RapiDoc doesn't have a built-in scroll-y-offset like ReDoc, but wrapping it in a container with controlled height and overflow does the job, especially when dealing with a fixed or floating header.

    Here’s what worked in my setup (using Next.js + TypeScript):

      <div className="w-full h-screen px-4 py-4">
        {/* @ts-expect-error: RapiDoc is a custom element not known to TypeScript */}
        <rapi-doc
          spec-url={specUrl}
          theme="light"
          render-style="read"
          show-header="false"
          allow-spec-url-load="false"
          allow-spec-file-load="false"
          allow-spec-url-download="false"
          style={{
            height: '100%',
            width: '100%',
            overflow: 'auto',
            display: 'block',
          }}
        />
      </div>

    This ensures:

    • Full-height scrollable documentation

    • No interference from fixed headers or parent container styles

    • Clean integration inside a React layout

    Hopefully helpful to others running into similar scroll behavior issues! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions