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-owl

v2.0.0

Published

Lobotomized Owl Selector for Tailwind CSS ==

Downloads

203

Readme

Lobotomized Owl Selector for Tailwind CSS

Introduced way ahead of its time the labotomized owl selector is a magnificent way to structure component spacing so that the individual component does not have to worry about its surrounding context.

Given a stereotypical example of a blog showing 10 posts the question is: how do you apply a uniform space between each of the 10 snippets without requiring each snippet to know where it falls in the list.

With out-of-the-box Tailwind you could do this with the following classes,

+------------------------+
|                        |
|  div.blog-post         |
|                        |
+------------------------+

2.5rem spacing

+------------------------+
|                        |
|  div.blog-post.mt-10   |
|                        |
+------------------------+

2.5rem spacing

+------------------------+
|                        |
|  div.blog-post.mt-10   |
|                        |
+------------------------+

In a React components you may have,

export default (props) => <div className={[!props.isFirst && 'mt-10', 'p-6', 'bg-black'].filter(className => className == true).join(' ')}>
  {/* blog post */}
</div>

Here we have a contextual class of .mt-10 applied to all posts that aren't the "first".

But that contextual class is mixed up with the component classes of .p-6, etc… it's confusing.

The owl selector allows you to ignore all that and apply a "spacing context" around the repeating items so their spacing will be defined by where the component is used. The new flow now looks like this,

+------------------------------+
|  div.o-10                    |
|                              |
|  +------------------------+  |
|  |                        |  |
|  |  div.blog-post         |  |
|  |                        |  |
|  +------------------------+  |
|                              |
|  same 2.5rem spacing         |
|                              |
|  +------------------------+  |
|  |                        |  |
|  |  div.blog-post         |  |
|  |                        |  |
|  +------------------------+  |
|                              |
|  same 2.5rem spacing         |
|                              |
|  +------------------------+  |
|  |                        |  |
|  |  div.blog-post         |  |
|  |                        |  |
|  +------------------------+  |
|                              |
+------------------------------+

The Owl utility for Tailwind CSS uses the margin config so a default install will have access to the following utility classes,

.o-0 > * + * { margin-top: 0; }
.o-1 > * + * { margin-top: 0.25rem; }
.o-2 > * + * { margin-top: 0.5rem; }
.o-3 > * + * { margin-top: 0.75rem; }
.o-4 > * + * { margin-top: 1rem; }
.o-5 > * + * { margin-top: 1.25rem; }
.o-6 > * + * { margin-top: 1.5rem; }
.o-8 > * + * { margin-top: 2rem; }
.o-10 > * + * { margin-top: 2.5rem; }
.o-12 > * + * { margin-top: 3rem; }
.o-16 > * + * { margin-top: 4rem; }
.o-20 > * + * { margin-top: 5rem; }
.o-24 > * + * { margin-top: 6rem; }
.o-32 > * + * { margin-top: 8rem; }
.o-40 > * + * { margin-top: 10rem; }
.o-48 > * + * { margin-top: 12rem; }
.o-56 > * + * { margin-top: 14rem; }
.o-64 > * + * { margin-top: 16rem; }
.o-px > * + * { margin-top: 1px; }

Installation

$ npm i --save-dev tailwindcss-owl

Usage

Within your tailwind.config.js file,

plugins: [
  // ... other plugins
  require('tailwindcss-owl')
  // ... other plugins
],