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

ttabs-svelte

v0.0.15

Published

A flexible layout management system with draggable, resizable tiles and tabs for Svelte applications. Like in VSCode

Readme

TTabs - Tiling Tabs Like in VSCode

Overview

TTabs is a layout system that allows users to create resizable and rearrangeable interfaces with tiling tabs. Like in VSCode.

How it Works

You create an instance of TTabs, register your components (can be any Svelte component), create a layout, and add instances of your components to tabs and columns.

API

Installation

npm install ttabs-svelte

Basic Usage

import { createTtabs, TTabsRoot } from 'ttabs-svelte';

// Create a ttabs instance
const ttabs = createTtabs({
  // Optional: provide initial state
  tiles: savedData?.tiles,
  focusedTab: savedData?.focusedTab
});

<TTabsRoot {ttabs} />

TtabsRoot is the container component that renders your layout and manages the root grid.

Creating Layouts

First, register your components:

// Register components that will be used in tabs
import MyComponent from './MyComponent.svelte';
ttabs.registerComponent('my-component', MyComponent);

Then create your layout using method chaining:

// Create a new grid and build the layout using method chaining
ttabs
  .newGrid()
  .newRow()
  .newColumn()
  .newPanel()
  .newTab("My Tab", true)
  .setComponent("my-component", { prop1: "value1" })
  .setFocused();

Working with Components

Once you've registered components, you can add them to tabs in various ways:

// Add component to a tab using method chaining
panel
  .newTab("Tab Name", true)
  .setComponent("my-component", {
    prop1: "value1"
  });

// Or set a component on an existing tab
const tab = ttabs.getTabObject(tabId);
tab.setComponent("my-component", { prop1: "value1" });

Managing Tabs

// Get the active panel
const activePanel = ttabs.getActivePanel();
const panel = ttabs.getPanelObject(activePanel);

// Create a new tab in a panel
panel
  .newTab("New Tab", true)
  .setFocused();

// Reset the entire layout
ttabs.resetTiles();

// Create a new layout from scratch
ttabs
  .newGrid()
  .newRow()
  .newColumn()
  .newPanel();

Persisting State

import { createTtabs, LocalStorageAdapter } from 'ttabs-svelte';
import { onMount } from 'svelte';

// Create a storage adapter with optional debounce time in ms
const storageAdapter = new LocalStorageAdapter("my-app-layout", 500);

// First, try to load saved state
const savedData = storageAdapter.load();

// Initialize ttabs with the loaded state
const ttabs = createTtabs({
  // Use saved tiles if available, otherwise use empty state
  tiles: savedData?.tiles,
  // Use saved focused tab if available
  focusedTab: savedData?.focusedTab,
});

// Connect the storage adapter to save changes
const unsubscribe = ttabs.subscribe((state) => {
  storageAdapter.save(state);
});

// Register cleanup on component destroy
onMount(() => {
  return () => {
    // Unsubscribe from state changes when component is destroyed
    unsubscribe();
  };
});

Hierarchical Structure

TileGrid -> TileRow[] -> TileColumn[] -> TileContent | TilePanel | TileGrid

TilePanel -> TileTab[] -> TileContent

Each level follows strict containment rules:

  • TileGrid contains only TileRows
  • TileRow contains only TileColumns
  • TileColumn contains exactly one of: TileContent, TilePanel, or nested TileGrid
  • TilePanel contains TileTabs
  • TileTab contains TileContent
  • TileContent contains reference to any content to be displayed in a tab or a column

Technical Details

Implementation

  • Built with Svelte 5, leveraging its reactive runes ($state, $effect) for state management
  • Each tile is a separate entity with a unique ID and parent-child relationships
  • Handles tab operations (moving, reordering, splitting panels)
  • Implements automatic cleanup of empty containers and redistribution of space when elements are removed
  • Hierarchical simplification to prevent unnecessary nesting of grid elements