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

@arnars/tailwindcss-vw-flexbox-grid

v1.3.0

Published

Tailwind CSS plugin to generate flexible flexbox grids with tooling included

Downloads

27

Readme

Flexbox grid system based on View width for Tailwind CSS

Requirements

This plugin requires Tailwind CSS 2.0 or later.

Installation

yarn add tailwindcss-vw-flexbox-grid

What is it?

alt text

This plugin creates all the columns on the above image.

On the image a background is provided directly in the columns - this is why the columns all seem gapless. In reality (and depending on your usecase) you would put a div inside the column and begin from there.

The lowest row is a mix of columns with and without gap, which is also possible. You can see where the text is, compared to the red overlay columns.

The red overlay, is an additional layer that I use for layouting and can toggle - not included in plugin, but built with the plugin.

Usage

This plugin uses the screen key in your Tailwind config’s theme. You can choose to configure it for only some of the screens, if your grid is consistent throughout multiple screens.

Make sure the keys of the screens in your config are matching the options provided to the plugin.

// tailwind.config.js
module.exports = {
    theme: {
        screens: {
            sm: '640px',
            md: '768px',
            lg: '1024px',
            xl: '1280px',
            '2xl': '1536px',
        },
    },
    plugins: [require('@arnars/tailwindcss-vw-flexbox-grid')({})],
};

Quick example

<!-- Basic container -->
<div class="w-full mx-auto space-y-12 min-w-page max-w-page">
    <!-- Row (only room for 4 columns below :md) -->
    <div class="row md:hidden">
        <div class="col col-2">Column</div>
        <div class="col col-1 indent-left-1">Column with left indent</div>
    </div>

    <!-- Row (only room for 6 columns below :lg) -->
    <div class="row hidden md:flex">
        <div class="col col-2">Column</div>
        <div class="col col-2 indent-right-1">Column with right indent</div>
    </div>

    <!-- Row (room for 12 columns) -->
    <div class="row hidden lg:flex">
        <div class="col col-6">Column</div>
        <div class="col-gapless col-gapless-2">Column without gaps</div>
        <div class="col col-4">Column</div>
    </div>
</div>

Default options

In the default options 4 screens are configured. All screen-related variables are in Arrays, where the index is corresponding the screen index.

const defaultOptions = {
    // Choose which screens to change settings for
    screens: [null, 'md', 'lg', '2xl'],
    // Number of column for different screens
    columns: [4, 6, 12, 12],
    // Page widths for different screens (if anything else but pixels, set as string. Pixels will be converted to em)
    pageWidths: ['100vw', '100vw', '100vw', 1536],
    // Column gaps for different screens
    columnGaps: [12, 12, 12, 12],
    // Page gaps for different screens
    pageGaps: [12, 12, 12, 12],
    // Page max width
    pageMaxWidth: 1536,
    // Page min width
    pageMinWidth: 320,
};

All of the above can be changed via an object provided to the plugin in tailwind.config.js like so:

// tailwind.config.js
module.exports = {
    plugins: [
        require('@arnars/tailwindcss-vw-flexbox-grid')({
            // Add options here
        }),
    ],
};

Column classes

.row {
    /* Handy wrapper for columns */
}

.col {
    /* Configuration class - needs to be there if you use col-x */
}

.col-gapless {
    /* Configuration class - needs to be there if you use col-gapless-x */
}

.col-x {
    /* Column - The x decides the width of your column */
}
.col-half {
    /* Column - Half width of all cols in all screens */
}
.col-full {
    /* Column - Full width of all cols in all screens */
}

.col-gapless-x {
    /* Column - The x decides the width of your column */
}
.col-gapless-half {
    /* Column - Half width of all cols in all screens */
}
.col-gapless-full {
    /* Column - Full width of all cols in all screens */
}

.indent-left-x {
    /* Indentation for columns - The x decides how many columns you want to indent */
}
.indent-right-x {
    /* Indentation for columns - The x decides how many columns you want to indent */
}
.indent-left-half {
    /* Indentation for columns - Half width of all columns */
}
.indent-right-half {
    /* Indentation for columns - Half width of all columns */
}
.indent-left-0 {
    /* Indentation for columns - Reset indentation */
}
.indent-right-0 {
    /* Indentation for columns - Reset indentation */
}

Additional classes - tooling

.gap-padding {
    /* Sets the current gap width as padding */
}
.gap-padding-x {
    /* Sets the current gap width as padding - left / right */
}
.gap-padding-y {
    /* Sets the current gap width as padding - top / bottom */
}
.gap-margin {
    /* Sets the current gap width as margin */
}
.gap-margin-x {
    /* Sets the current gap width as margin - left / right */
}
.gap-margin-y {
    /* Sets the current gap width as margin - top / bottom */
}

Gotchas

When using .col-x, box-sizing is set to content-box and padding is used to archieve the gap-effect. This is because I would like to be able to use the .indent-left/right-x which works with margin.

When using .col-gapless-x, no gap is needed and box-sizing is set to border-box.

It often makes sense to add a child div to the column-div in order to avoid overriding essential behavior.