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

tailwindcss-grid-area

v1.0.10

Published

Add support for Grid areas within TailwindCSS

Downloads

551

Readme

TailwindCSS plugin for Grid Areas

Add support for Grid areas within TailwindCSS

Running Tests Publish Release NPM Version

Usage

This plugin adds two new utilities for TailwindCSS to work with grid areas - grid-areas-[<areas>] and grid-area-[<area>] (or grid-area/<named-area>)

<div class="grid grid-cols-5 grid-rows-3 bg-yellow-100">

    <div class="p-10 bg-blue-300 grid-area-auto"></div>

    <div class="p-10 bg-red-300 grid-area-[2/2/span_2/span_3]"></div>

</div>

Result:

result for grid area

Generated CSS:

.grid-area-auto {
  grid-area: auto;
}

.grid-area-\[2\/2\/span_2\/span_3\] {
  grid-area: 2/2/span 2/span 3;
}

Named Areas

<div class="grid grid-areas-['sidebar_center_left'_'sidebar_footer_footer']">

    <div class="p-10 bg-blue-300 grid-area/left"></div>

    <div class="p-10 bg-yellow-300 grid-area/center"></div>

    <div class="p-10 bg-red-300 grid-area/sidebar"></div>

    <div class="p-10 bg-green-300 grid-area/footer"></div>

</div>

Result:

result for grid named area

Generated CSS:

.grid-area\/left {
  grid-area: left;
}

.grid-area\/center {
  grid-area: center;
}

.grid-area\/sidebar {
  grid-area: sidebar;
}

.grid-area\/footer {
  grid-area: footer;
}

.grid-areas-\[\'sidebar_center_left\'_\'sidebar_footer_footer\'\] {
  grid-template-areas: 'sidebar center left' 'sidebar footer footer';
}

Installation

npm i tailwindcss-grid-area

Require plugin within plugins section of tailwind.config.js

// tailwind.config.js

module.exports = {
    // ...
    
    plugins: [
        require('tailwindcss-grid-area'),
    ],
}

Configuration

Plugin provides some default utilities for grid-area - same syntax as for global values for grid-area CSS property

| Utility | Generated CSS | | --- | --- | | grid-area, grid-area-auto | grid-area: auto | | grid-area-inherit | grid-area: inherit | | grid-area-initial | grid-area: initial | | grid-area-revert | grid-area: revert | | grid-area-layer | grid-area: revert-layer | | grid-area-unset | grid-area: unset |

Arbitrary Values

There are no default properties for grid-areas (as it is purely user-configured setting). However if you wish to use custom defined utility register it under gridAreas key

// tailwind.config.js

module.exports = {
    // ...
    
    theme: {
        extend: {
            gridAreas: {
                app: "'header header' 'sidebar main' 'sidebar footer'",
            },
        },
    },
}
<div class="grid grid-areas-app"></div>

More about grid-template-areas you may find on MDN

Same valid for grid-area utility but key name is gridArea

// tailwind.config.js

module.exports = {
    // ...
    
    theme: {
        extend: {
            gridArea: {
                custom: '1 / 1 / span 2 / 3',
            },
        },
    },
}
<div class="grid-area-custom"></div>

When working with arbitrary values remember that Tailwind does NOT recognize spaces - use underscore _ instead

<div class="grid-area-[1_/_1_/_span_2_/_3]"></div>

<!-- Or -->
<div class="grid-area-[1/1/span_2/3]"></div>

Using Labels

When working with named grid areas you may use Tailwind labels instead of arbitrary variants

<div class="grid-area/header"></div>

<!-- Same as -->
<div class="grid-area-[header]"></div>

License

Open-source under MIT license