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

split-views

v3.0.2

Published

A lightweight, zero-dependency TypeScript library for creating resizable split views (panes) in web applications.

Readme

SplitViews

A lightweight, framework-agnostic split-pane library for resizable layouts.
Zero dependencies. Modern Pointer Events. CSS-variable driven sizing.

  • Modern: Uses Pointer Events + setPointerCapture (no global listeners)
  • Performant: Batched DOM writes, CSS variables for sizes, minimal reflows
  • 🧩 Composable: Works with nested splits, no framework required
  • Accessible: ARIA roles, orientations, keyboard focusable gutters

Split views

Demo

import SplitViews from "split-views";

Or include it via jsDelivr CDN (UMD):

<script
  src="https://cdn.jsdelivr.net/npm/split-views/dist/index.umd.min.js"
></script>
<!-- Access via global object : window.SplitViews -->
<!-- Or via unpkg -->
<script src="https://unpkg.com/split-views"></script>

Quick Start

HTML:

<div id="editor" class="split-root" style="height: 400px">
  <div>Left Pane</div>
  <div>Right Pane</div>
</div>

JavaScript:

import SplitViews from "splitviews";

const split = SplitViews({
  root: "#editor",
  direction: "horizontal", // 'vertical' or 'horizontal' (default)
  gutterSize: 8,
  sizes: [30, 70], // percentages; defaults to equal split
  minSize: [120, 200], // px per pane or single px applied to all
  snapOffset: 8, // px tolerance before snapping to min
  onDrag: (sizes) => {
    console.log("resizing...", sizes);
  },
  onDragEnd: (sizes) => {
    console.log("final sizes:", sizes);
  },
});

Options

| Option | Type | Default | Description | | ----------------- | ---------------------------- | ---------------- | --------------------------------------------------------- | | root | HTMLElement \| string | required | Container element or selector. Children become panes. | | direction | 'horizontal' \| 'vertical' | 'horizontal' | Split direction. | | gutterSize | number | 10 | Gutter thickness in px. | | gutterClassName | string | 'split-gutter' | Class applied to each gutter. | | minSize | number \| number[] | 0 | Per-pane minimum size in px (array) or single px for all. | | sizes | number[] | equal split | Initial sizes in percentages. | | snapOffset | number | 0 | Extra px tolerance before snapping to min. | | onDrag | (sizes:number[])=>void | — | Called on every drag frame. | | onDragEnd | (sizes:number[])=>void | — | Called when dragging stops. |


API

  • destroy(): Removes gutters and resets styles
  • setSizes(sizes: number[]): Programmatically set pane sizes
  • getSizes(): number[]: Get current pane sizes

Styling

The library sets:

  • display: flex and flex-direction on root
  • flex-basis per pane (via CSS variables)
  • Basic cursor and touch-action on gutters

You control the look of gutters:

.split-root {
  contain: layout size style; /* hint for performance */
}

.split-gutter {
  background: transparent;
  position: relative;
}

/* Visible hairline */
.split-gutter::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.1);
}

.split-gutter:hover::before {
  background: rgba(0, 0, 0, 0.2);
}

CSS variables you can use:

  • --pane-<index>-size: applied as flex-basis for each pane
  • --split-gutter-size: gutter thickness
  • --split-cursor: cursor type (col-resize / row-resize)

Accessibility

Gutters automatically have:

  • role="separator"
  • aria-orientation="vertical" (for horizontal split) or "horizontal" (for vertical split)
  • tabIndex="0" so they can be focused

Nested Splits

You can nest multiple instances:

const outer = SplitViews({ root: "#root", direction: "horizontal" });
const inner = SplitViews({
  root: '#root [data-split-pane="1"]',
  direction: "vertical",
});

Each instance manages only its direct children.


Performance Notes

  • Uses setPointerCapture → no global listeners.
  • DOM writes batched with requestAnimationFrame.
  • CSS variables used for sizes → fast style recalculation.
  • Avoid heavy work in onDrag; debounce if needed.
  • Clean destroy() ensures no leaks.

Browser Support

  • Chromium, Firefox, Safari (modern versions with Pointer Events).
  • No IE support (Pointer Events required).

License

MIT © 2025