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

@hydroperx/tiles

v2.2.16

Published

Metro tile layout

Readme

@hydroperx/tiles

Base layout implementation for Windows 8 like live tiles in HTML5.

Documentation

Structure

Positioning style:

  • Cascading transform: translateX(...) translateY(...)
  • Uses the cascading em unit for measurement everywhere (which means the (?inherited) font-size).

Group element tag:

  • div

Group element attribute:

  • Tiles.ATTR_ID: the group ID.

Group element attribute:

  • Tiles.ATTR_DRAGGING: false or true.

Group element:

  • Consists of:
    • A group label div (contains a group label text div)
    • A group tiles div (where the tiles float).

Tile element tag:

  • A button, consisting of a content div where the user may apply custom transforms such as tilting.

Tile element attribute:

  • Tiles.ATTR_ID: the tile ID.

Tile element attribute

  • Tiles.ATTR_SIZE: the tile size (small, medium, wide or large).

Tile element attribute

  • Tiles.ATTR_DRAGGING: false or true.

Tile element attribute:

  • Tiles.ATTR_CHECKED: false or true.

Tile size:

  • Supports small (1x1), medium (2x2), wide (4x2) and large tiles (4x4).

Getting started

import { Tiles } from "@hydroperx/tiles";

const container = document.querySelector("#container")!;

// Create layout
const tiles = new Tiles({
  element: container,
  direction: "horizontal",
  classNames: {
    group: "group",
    groupLabel: "group-label",
    groupLabelText: "group-label-text",
    groupTiles: "group-tiles",
    tile: "tile",
    tileContent: "tile-content",
  },
  smallSize: 3.625,
  tileGap: 0.6,
  groupGap: 3,
  labelHeight: 2,
  height: 6,
});

// Handle click in a tile
tiles.on("click", ({ detail: { tile } }) => {
  if (tile == "purple1") {
    alert("one!");
  }
});

// Handle tile addition
tiles.on("addedtile", ({ detail: { tile, button, contentDiv } }) => {
  if (tile.id.startsWith("purple")) {
    button.style.background = "purple";
  }
});

// Group 1
tiles.addGroup({
  id: "group1",
  label: "Group 1",
});

// Tile 1
tiles.addTile({
  id: "purple1",
  group: "group1",
  size: "large",
});

// Tile 2
tiles.addTile({
  id: "purple2",
  group: "group1",
  size: "wide",
});

// Disposal
tiles.destroy();

Events

addedgroup

Dispatched when a new group is added. Event is given a CustomEvent<{ group: Group, div: HTMLDivElement, labelDiv: HTMLDivElement, tilesDiv: HTMLDivElement }> object. This is also dispatched when automatic groups are created (such as when a tile is dropped far away in no existing group).

tiles.on("addedgroup", ({ detail: { group, div, labelDiv, labelTextDiv, tilesDiv } }) => {
    //
});

addedtile

Dispatched when a new tile is added. Event is given a CustomEvent<{ tile: Tile, button: HTMLButtonElement, contentDiv: HTMLDivElement }> object.

tiles.on("addedtile", ({ detail: { tile, button, contentDiv } }) => {
    //
});

stateupdate

Dispatched whenever the state is updated. Event is given a CustomEvent<State> object.

tiles.on("stateupdate", ({ detail: state }) => {
    //
});

dragstart

Event is given a CustomEvent<{ tile: HTMLButtonElement }> object.

tiles.on("dragstart", ({ detail: { tile } }) => {
    //
});

drag

Event is given a CustomEvent<{ tile: HTMLButtonElement }> object.

tiles.on("drag", ({ detail: { tile } }) => {
    //
});

dragend

Event is given a CustomEvent<{ tile: HTMLButtonElement }> object.

tiles.on("dragend", ({ detail: { tile } }) => {
    //
});

groupdragstart

Event is given a CustomEvent<{ group: HTMLDivElement }> object.

tiles.on("groupdragstart", ({ detail: { group } }) => {
    //
});

groupdrag

Event is given a CustomEvent<{ group: HTMLDivElement }> object.

tiles.on("groupdrag", ({ detail: { group } }) => {
    //
});

groupdragend

Event is given a CustomEvent<{ group: HTMLDivElement }> object.

tiles.on("groupdragend", ({ detail: { group } }) => {
    //
});

selectionchange

Event is given a CustomEvent<{ tiles: string[] }> object.

tiles.on("selectionchange", ({ detail: { tiles } }) => {
    //
});

click

Event is given a CustomEvent<{ tile: string }> object.

tiles.on("click", ({ detail: { tile } }) => {
    //
});

Style recommendations

  • Do not add border, margin, padding or scale to classNames.group to avoid inconsistencies in grid-snapping.
  • Do not add border, margin, padding or scale to classNames.groupTiles to avoid inconsistencies in grid-snapping.
  • Do not add margin or scale to classNames.tile. Scale may be used in classNames.tileContent.
  • Outline mayn't work well in className.tile, as it may be clipped off; prefer a border.

Rearranging

If your container starts at zero scale, then it is necessary to manually call .rearrangeOverMinimumScale() for the first time the container opens.

For example:

const aborter = base_tiles.current!.rearrangeOverMinimumScale();

// Abort when necessary
aborter.abort();

License

Apache 2.0