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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-bento-box

v1.0.8

Published

Bento box layouts

Downloads

615

Readme

React Bento Box

A React library for creating bento box layouts

Install

npm install react-bento-box

Usage

BentoBoxContainer

The container that will contain your components. BentoBoxContainer will fill the full width and height of the parent component.

import { BentoBoxContainer } from "react-bento-box";

...

<div style={{ width: "100dvw", height: "100dvh" }}>
  <BentoBoxContainer rows={4} cols={6}>
    ...
  </BentoBoxContainer>
</div>
// parameters
rows: number; // (required) number of rows displayed
cols: number; // (required) number of columns displayed
gap?: "sm" | "md" | "lg" | "xl"; // (optional, default "md") spacing between BentoBoxItems

BentoBoxItem

Must be in a BentoBoxContainer. The individual items that will make up the parts of your bento box. Endless possible layouts.

import { BentoBoxItem } from "react-bento-box";

...

// this item will start in row 0 and col 1 and be 1 row in height and 2 cols in width
<BentoBoxItem start={[0, 1]} size={[1, 2]}>
  ...
</BentoBoxItem>
// parameters
start: number[]; // (required) defined as [row, col] to start the top left element, 0 based index
size: number[]; // (required) defined as [#rows, #cols] to span
shadow?: boolean; // (optional) applies a shadow to the item
shadowColor?: string; // (optional) changes the color of the shadow

CornerButton

Must be in a BentoBoxItem. Useful component for embedded buttons in the BentoBoxItem.

import { Corner Button } from "react-bento-box";

...

<CornerButton>
  Click me!
</CornerButton>
// parameters
gap?: "sm" | "md" | "lg"; // (optional, default "md") size of the button

Examples

Small Layout

alt text

import { BentoBoxContainer, BentoBoxItem, CornerButton } from "react-bento-box";
import "./App.css";

function App() {
  return (
    <div
      style={{
        width: "100dvw",
        height: "100dvh",
      }}
    >
      <BentoBoxContainer rows={2} cols={3}>
        <BentoBoxItem className="red" start={[0, 0]} size={[1, 2]}>
          <div className="content stack">
            <h4>Start: row=0, col=0</h4>
            <h4>Size: rows=1, cols=2</h4>
          </div>
          <CornerButton size="lg">Corner Button</CornerButton>
        </BentoBoxItem>

        <BentoBoxItem className="pink" start={[0, 2]} size={[1, 1]}>
          <div className="content stack">
            <h4>Start: row=0, col=2</h4>
            <h4>Size: rows=1, cols=1</h4>
          </div>
        </BentoBoxItem>

        <BentoBoxItem className="violet" start={[1, 0]} size={[1, 1]}>
          <div className="content stack">
            <h4>Start: row=1, col=0</h4>
            <h4>Size: rows=1, cols=1</h4>
          </div>
        </BentoBoxItem>

        <BentoBoxItem className="orange" start={[1, 1]} size={[1, 2]}>
          <div className="content stack">
            <h4>Start: row=1, col=1</h4>
            <h4>Size: rows=1, cols=2</h4>
          </div>
        </BentoBoxItem>
      </BentoBoxContainer>
    </div>
  );
}

export default App;

Large Layout

alt text

import { BentoBoxContainer, BentoBoxItem, CornerButton } from "react-bento-box";
import "./App.css";

function App() {
  return (
    <div
      style={{
        width: "100dvw",
        height: "100dvh",
      }}
    >
      <BentoBoxContainer rows={5} cols={7} gap="lg">
        <BentoBoxItem className="blue" start={[0, 0]} size={[1, 1]} shadow>
          <div className="content">This is content!</div>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[0, 1]} size={[1, 1]} shadow>
          <div className="content stack">
            <h4>Title</h4>
            <h1>Stat</h1>
            <h4>Subtitle</h4>
          </div>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[0, 2]} size={[1, 1]} shadow>
          <div className="content stack">
            <h4>Title</h4>
            <h1>Stat</h1>
            <h4>Subtitle</h4>
          </div>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[0, 3]} size={[1, 2]} shadow>
          <div className="content">
            This is a really long description of content that goes on and on!
          </div>
          <CornerButton size="sm">Link</CornerButton>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[0, 5]} size={[1, 2]} shadow>
          <div className="content stack">
            <h4>Title</h4>
            <h1>Big Number</h1>
            <h4>Subtitle</h4>
          </div>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[1, 0]} size={[2, 2]} shadow>
          <div className="content stack">
            <h4>Title</h4>
            <h1>Big Number</h1>
            <h4>Subtitle</h4>
          </div>
          <CornerButton>See More!</CornerButton>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[3, 0]} size={[1, 1]} shadow>
          <div className="content stack">
            <h4>Title</h4>
            <h1>Stat</h1>
            <h4>Subtitle</h4>
          </div>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[3, 1]} size={[1, 1]} shadow>
          <div className="content stack">
            <h4>Title</h4>
            <h1>Stat</h1>
            <h4>Subtitle</h4>
          </div>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[1, 2]} size={[3, 3]} shadow>
          <div className="content image">Fake Image</div>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[1, 5]} size={[2, 1]} shadow>
          <div className="content stack">
            <h4>Title</h4>
            <h1>Stat</h1>
            <h1>Stat</h1>
            <h4>Subtitle</h4>
          </div>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[1, 6]} size={[2, 1]} shadow>
          <div className="content stack">
            <h4>Title</h4>
            <h1>Stat</h1>
            <h1>Stat</h1>
            <h4>Subtitle</h4>
          </div>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[3, 5]} size={[2, 2]} shadow>
          <div className="content stack">
            <h4>Title</h4>
            <h1>Big Number</h1>
          </div>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[4, 0]} size={[1, 2]} shadow>
          <div className="content ">More content down here!</div>
        </BentoBoxItem>

        <BentoBoxItem className="blue" start={[4, 2]} size={[1, 3]} shadow>
          <div className="content stack">
            <h4>Title</h4>
            <h1>Big Number</h1>
          </div>
        </BentoBoxItem>
      </BentoBoxContainer>
    </div>
  );
}

export default App;