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-interaction-media

v0.1.0

Published

Tailwind CSS variants for detecting the interaction media features of a device.

Downloads

607

Readme

Tailwind CSS Interaction Media Variants

Tailwind CSS variants for detecting the interaction media features of a device.

Note: This project is under active development and may be subject to breaking changes until it reaches a stable version 1.0.0.

Installation

Install with your favorite NodeJS package manager:

$ npm install tailwindcss-interaction-media

$ yarn add tailwindcss-interaction-media

Add to your Tailwind CSS config file:

// tailwind.config.js

module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('tailwindcss-interaction-media')
  ],
}

Usage

This plugin adds variants for the CSS interaction media features hover, pointer, any-hover, and any-pointer, as well as some semantically named combinations based on this article by Patrick H. Lauke.

These variants help address problems when creating adaptive designs using Tailwind CSS. A common issue when adapting for touchscreen devices is having the utilities applied by the hover: variant "stick" after being tapped.

This can be trivially addressed by using the any-can-hover: variant in combinations with the hover: variant so that hover utilities are applied when the device has any pointer with hover capabilities. This way we can support modern hybrid-input devices such as smartphones with a bluetooth mouse.

Hover

These variants detect the hover capabilities of the device's interaction media.

  • can-hover: - Applies a utility if the device's primary pointer can hover.
  • cannot-hover: - Applies a utility if the device's primary pointer cannot hover.
  • any-can-hover: - Applies a utility if any of the device's pointers can hover.
  • any-cannot-hover: - Applies a utility if any of the device's pointers cannot hover.
  • none-can-hover: - Applies a utility if none of the device's pointers can hover.

Note: Be weary about the logical differences between any-cannot-hover and none-can-hover.

Pointer

These variants detect the pointer capabilities of the device's interaction media.

  • pointer-coarse: - Applies a utility if the device's primary pointer has coarse accuracy such as touch.
  • pointer-fine: - Applies a utility if the device's primary pointer has fine accuracy such as a mouse cursor.
  • pointer-none: - Applies a utility if the device has no primary pointer.
  • any-pointer-coarse: - Applies a utility if any of the device's pointers have coarse accuracy such as touch.
  • any-pointer-fine: - Applies a utility if any of the device's pointers have fine accuracy such as a mouse cursor.
  • no-pointer-coarse: - Applies a utility if none of the device's pointers have coarse accuracy.
  • no-pointer-fine: - Applies a utility if none of the device's pointers have fine accuracy.
  • no-pointer: - Applies a utility if the device has no pointers at all.

Semantic

These variants are logical combinations of the above variants expressed with a semantic name. They are based off the truth table from this article.

  • only-touch: - Applies a utility if the device only has touch interaction available, such as a touchscreen or a pen without hover capabilities.
  • only-cursor: - Applies a utility if the device only has cursor interaction available such as a mouse or a pen with hover capabilities.
  • touch+cursor: - Applies a utility if the device has both cursor and touch interaction available.

License

Tailwind CSS Interaction Media is MIT licensed.