Skip to content

Sticky List Section

beta

The StickyListSection component provides sticky section headers that pin to the top of a scroll container while the section is visible, then push out as the next section scrolls in. Built with IntersectionObserver, it detects when a header becomes stuck and applies a subtle shadow.

Contained Mode

Use contained when the StickyListSection is nested inside intermediate wrapper elements (form inputs, layout stacks, cards) but the drawer body is still the scroll container. This mode uses --cn-sticky-container-padding to bleed the header out to the drawer edges through the wrapper layers.

Usage

import { StickyListSection } from '@harnessio/ui/components'
// Direct usage inside a drawer body
<StickyListSection.Root>
<StickyListSection.Header>
<div>Section Title</div>
</StickyListSection.Header>
<StickyListSection.Content>
{/* Scrollable list content */}
</StickyListSection.Content>
</StickyListSection.Root>
// Contained mode — inside form wrappers
<div style={{ '--cn-sticky-container-padding': '...' }}>
<StickyListSection.Root contained>
<StickyListSection.Header>
<div>Section Title</div>
</StickyListSection.Header>
<StickyListSection.Content>
{/* List content */}
</StickyListSection.Content>
</StickyListSection.Root>
</div>

Anatomy

<StickyListSection.Root> {/* Container with sentinel for stuck detection */}
<StickyListSection.Header> {/* Sticky header — gains shadow when stuck */}
{children}
</StickyListSection.Header>
<StickyListSection.Content> {/* Section content */}
{children}
</StickyListSection.Content>
</StickyListSection.Root>

API Reference

StickyListSection.Root

The container component that manages stuck detection via IntersectionObserver.

Prop
Required
Default
Type
childrentrueReactNode
containedfalseboolean
classNamefalsestring

StickyListSection.Header

The sticky header that pins to the top of the scroll container. Applies a shadow when stuck.

Prop
Required
Default
Type
childrentrueReactNode
classNamefalsestring

StickyListSection.Content

Wrapper for the section’s scrollable content.

Prop
Required
Default
Type
childrentrueReactNode
classNamefalsestring