npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-fluid-toc

v0.1.1

Published

A portable React table-of-contents with a fluid animated SVG rail, range scroll-spy highlight, and a travelling dot. Zero runtime deps, themed via CSS variables.

Readme

react-fluid-toc

A portable React table of contents with a fluid animated SVG rail: a continuous bezier track, a range-based scroll-spy highlight, and a dot that rides the line to the active section — plus auto-scroll of its own overflow.

  • 🪶 Zero runtime dependencies — React is the only peer.
  • 🎨 No Tailwind, no required CSS import — themed with CSS variables.
  • ⚡ SSR-friendly — renders from a prepared items array.
  • 🧩 Unopinionated layout — you position it (sticky, drawer, sidebar).

react-fluid-toc demo — the rail highlight and dot track the scroll position

Install

npm install react-fluid-toc

Quick start

import { FluidToc, type TocItem } from 'react-fluid-toc'

const items: TocItem[] = [
  { id: 'intro', text: 'Introduction', depth: 2 },
  { id: 'install', text: 'Install', depth: 2 },
  { id: 'options', text: 'Options', depth: 3 }
]

export function Sidebar() {
  return (
    <aside
      style={{
        position: 'sticky',
        top: 96,
        maxHeight: 'calc(100vh - 8rem)',
        overflowY: 'auto'
      }}
    >
      <FluidToc items={items} scrollOffset={96} />
    </aside>
  )
}

items[].id must match the id of the heading elements on the page — those are the anchors the entries link and scroll to.

Props

| Prop | Type | Default | Description | | -------------- | ------------------------------------------- | ------- | ----------------------------------------------------------------------- | | items | TocItem[] | — | The outline. { id, text, depth }. | | scrollOffset | number | 0 | Pixels to clear for a fixed header (scroll-spy band + click scrolling). | | smoothScroll | boolean | true | Smooth-scroll on click / auto-scroll. | | autoScroll | boolean | true | Scroll the component's own box to keep the active entry visible. | | onItemClick | (id: string, e: React.MouseEvent) => void | — | Override the default click-to-scroll behaviour. | | className | string | — | Applied to the root <nav>. | | style | React.CSSProperties | — | Merged onto the root <nav>. |

Theming

Colors come from CSS custom properties (with fallbacks), so it looks fine with no setup and is fully overridable. Set these anywhere above the component:

| Variable | Purpose | Default | | -------------------- | ------------------- | -------------------- | | --fluid-toc-rail | inactive track line | rgba(0, 0, 0, 0.1) | | --fluid-toc-accent | active line + dot | currentColor | | --fluid-toc-muted | inactive item text | #71717a | | --fluid-toc-active | active item text | --fluid-toc-accent |

.docs-toc {
  --fluid-toc-accent: #6366f1;
  --fluid-toc-muted: #71717a;
}
@media (prefers-color-scheme: dark) {
  .docs-toc {
    --fluid-toc-rail: rgba(255, 255, 255, 0.12);
    --fluid-toc-muted: #a1a1aa;
  }
}

Preparing items

The component is data-driven; you own how the outline is produced.

Server-side (recommended for SSR): extract headings when you render the content (from your markdown/MDX pipeline or your HTML) and pass the array down.

Client-side convenience: extractHeadings reads rendered headings from the DOM.

import { extractHeadings } from 'react-fluid-toc'

const items = extractHeadings(document.querySelector('.article')!) // h2, h3
const custom = extractHeadings(container, 'h2, h3, h4') // custom selector

extractHeadings(root, selector?) returns { id, text, depth }[], skipping headings without an id.

How it works

The rail is one continuous SVG path built from the rendered anchor offsets, with bezier joins between indent levels. The accent-colored copy of that path is revealed through an animated clip-path window, and a dot is pinned to the leading edge — all driven by CSS variables set imperatively, so scrolling never re-renders the SVG. Active detection is a range (first..last visible heading) with a nearest-heading fallback so the indicator never disappears.

Credits

The animated rail is a re-implementation of the table of contents in fumadocs. The SVG technique behind it — building one path from the item positions and revealing it through an animated mask/clip — is explained by fumadocs' author in "The Art of SVG". All credit for the original idea goes there.

License

MIT © Yancey Leo