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

kaplay-layout

v1.0.1

Published

a wrapper around Yoga that provides real CSS flexbox in kaplay.

Readme

kaplay-layout

implements flexboxs (and possibly grids?) in kaplay using the Yoga layout engine.

installation

install the NPM library. (added --force if you're using alpha versions )

npm install --force kaplay-layout

and then initialize the plugin.

import kaplay from "kaplay"
import kaplayLayout from "kaplay-layout"

export const k = kaplay({
  global: false,
  plugins: [await kaplayLayout()],
})

usage

kaplay-layout is designed to be as intuitive as possible.

// add a flexbox to the scene
const parent = k.add([
  k.pos(),
  // use rect as a background.
  // you may omit this.
  k.rect(0, 0),
  k.flex(),
])

// add a static child to the parent
// static means its size is not controlled by the plugin.
// it won't grow or shrink.
parent.add([k.pos(), k.rect(20, 20), k.static()])

// add another child to the parent
// it will be placed next to the previous child
const box = parent.add([k.pos(), k.rect(20, 20), k.static()])

// then you can just change the static object sizes!
// and the flexbox will grow accordingly.
k.onClick(() => {
  box.width += 4
  box.width += 4
})

do note that layout calculations happens during updates. that means you can't read object sizes instantly after they are added to the scene. this is to prevent unnecessary calculations. though you can force a calculation imediately using calculateLayout.

since kaplay-layout only uses position under the hood. scale, rotation, shaders, anchors etc. should just works.

const parent = k.add([k.pos(), k.flexbox(), k.scale(1.1)])
const nested = parent.add([
  k.flexbox(),
  k.pos(),
  k.rotate(45),
  k.anchor("center"),
])
nested.add([k.pos(), k.static(), k.text("it just works!")])

(hint: you should always use pos to avoid edge cases even if flexbox works without them)

percent lentghs and every flexbox properties also works.

const parent = k.add([
  k.pos(),
  k.rect(0, 0),
  k.outline(1),
  k.flexbox({
    minWidth: 100,
    padding: 10,
    minHeight: 100,
    flexDirection: "row",
    justifyContent: "start",
    alignItem: "strech",
  }),
])
parent.add([
  k.pos(),
  k.rect(0, 0),
  k.outline(1),
  k.flexbox({
    maxHeight: "20%",
    flex: 1,
  }),
])

documentation

check out the documentation.

textbox?

I planned to add align baseline and proper text support... soon. bear with me a little.

grids?

taffy is a layout engine that supports both grids and flexboxes. but it doesn't have an offical WASM bindings right now.

I'm definitely not learning rust just to port it over to JS. but when it finally does, I'll migrate over to it. I promise that the API won't change too much.

contribute

feel free to submit things (do try to format them proper though).

clone the repo and then install the dependencies,

git clone https://github.com/hinum/kaplay-layout.git
cd ./kaplay-layout
npm install

to build the repo run,

npm run build

to run the tests run, (you need to have a browser installed ofc)

npm run test

to build and optionally preview the documentation run,

npm run docs
npm run docs:preview