From a5dc31a791ccffcb2deb5fee020996297043b176 Mon Sep 17 00:00:00 2001 From: Zeno Kapitein Date: Wed, 17 Jun 2026 10:35:08 +0200 Subject: [PATCH] Stick the page actions bar to the top of the viewport Make the page header actions (the "On this page" toggle and the assistant / page actions) stick to the top of the viewport on non-mobile viewports, so they stay reachable while scrolling long pages such as API references (RND-11139). - PageHeader: render the actions as a sibling of `
` (a direct child of the scrolling `
`) so its sticky containing block is the full page rather than the short header, which is why it scrolled away before. It pins padded just below the site header using the same server-default + client CSS-var pattern as the table of contents, and drops below the "On this page" panel when that is expanded as an overlay so it doesn't show on top of it. - OpenAPI: shift the sticky code-sample preview down so it clears the newly-sticky bar, and leave a small gap at the bottom of the viewport. - Button: keep secondary buttons' background in the flat depth style instead of making them transparent, so the sticky actions stay visible over the content they scroll past. Co-Authored-By: Claude Opus 4.8 --- .../components/DocumentView/OpenAPI/style.css | 4 +- .../src/components/PageBody/PageHeader.tsx | 178 +++++++++++------- .../src/components/primitives/Button.tsx | 2 - 3 files changed, 108 insertions(+), 76 deletions(-) diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/style.css b/packages/gitbook/src/components/DocumentView/OpenAPI/style.css index ee840de73..81b4e3247 100644 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/style.css +++ b/packages/gitbook/src/components/DocumentView/OpenAPI/style.css @@ -149,7 +149,9 @@ } .openapi-column-preview { - @apply flex flex-col flex-1 xl:max-2xl:pt-20 lg:pt-6 sticky self-start max-h-[calc(100vh-var(--toc-top-offset))] top-(--toc-top-offset); + /* Shift down by ~2rem so the pinned preview clears the sticky "On this page" / + page-actions bar below the header, and leave a 1rem gap at the bottom of the viewport. */ + @apply flex flex-col flex-1 xl:max-2xl:pt-8 lg:pt-6 sticky self-start max-h-[calc(100vh-var(--toc-top-offset)-3rem)] top-[calc(var(--toc-top-offset)+2rem)]; } .openapi-column-preview-body { diff --git a/packages/gitbook/src/components/PageBody/PageHeader.tsx b/packages/gitbook/src/components/PageBody/PageHeader.tsx index d118de9ae..a71085849 100644 --- a/packages/gitbook/src/components/PageBody/PageHeader.tsx +++ b/packages/gitbook/src/components/PageBody/PageHeader.tsx @@ -47,11 +47,34 @@ export async function PageHeader(props: { } return ( -
+ <> + {/* Page actions (assistant, "On this page", ...). Rendered as a sibling of the +
— i.e. a direct child of the scrolling
— so that on larger screens + it can stick to the top of the viewport while the page is scrolled. If it lived + inside the
, its sticky containing block would be the short header and it + would scroll away with it. */}
{hasPageActions ? ( @@ -70,78 +93,87 @@ export async function PageHeader(props: {
- {hasAncestors && ( -
+ + ); + })} + + + )} + + {page.layout.title ? ( +

+ + {page.title} +

+ ) : null} + {page.description && page.layout.description ? ( +

+ {page.description} +

+ ) : null} +
+ ); } diff --git a/packages/gitbook/src/components/primitives/Button.tsx b/packages/gitbook/src/components/primitives/Button.tsx index ebe422e30..14a31dbbc 100644 --- a/packages/gitbook/src/components/primitives/Button.tsx +++ b/packages/gitbook/src/components/primitives/Button.tsx @@ -58,10 +58,8 @@ export const variantClasses = { ], secondary: [ 'bg-tint', - 'depth-flat:bg-transparent', 'text-tint', 'hover:bg-tint-hover', - 'hover:not-disabled:depth-flat:bg-tint-hover', 'hover:not-disabled:text-tint', 'contrast-more:bg-tint-subtle', 'disabled:bg-transparent',