New Content Pill

Holds new feed items behind a "5 new posts" pill, so the feed doesn't jump under the reader's finger while they read or tap.

StopsFeed jumped while I was tapping

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/new-content-pill.json

The files land in your project. They're yours to edit.

What it catches

  • Posts shifting under a tap when new items arrive
  • Reader losing their place mid-feed
  • Inserts directly when the reader is already at the top

Props

NewContentPill props
PropTypeDefault
items* (required)

The live list, newest first. New items arrive at the start.

T[]—
getKey* (required)

A stable key for each item.

(item: T) => string—
renderItem* (required)

Renders one item.

(item: T, index: number) => React.ReactNode—
label

Pill text. `{count}` is filled in.

string"{count} new posts"
labelOne

Pill text for a single new item.

string"1 new post"
topThreshold

Within this many pixels of the top counts as "at the top", where new items go straight in.

number8
scrollTarget

What scrolls. "self" (default) makes this element the scroll box. "window" is for feeds where the whole page scrolls; a function returns another scrolling ancestor (an app shell's main panel).

"self" | "window" | (() => HTMLElement | null)"self"
topOffset

Height of a sticky header over the feed when the page or an ancestor scrolls. The pill sits below it.

number0

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Pill is a button; the count is announced via role=status
  • After tapping, focus moves to the first feed item without scrolling past it
  • Smooth scroll and the pill animation are skipped under reduced motion

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Assumes a newest-first list where new items arrive at the start
  • Needs a stable key per item (getKey)
  • Doesn't virtualise long lists

What it stops

Feed jumped while I was tapping

Also known as

new posts · feed · timeline · infinite scroll · live updates · chat · layout shift · pill

Dependencies

Pairs well with