🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

tailwindcss-device

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tailwindcss-device

TailwindCSS plugin to add variants for input device detection using `@media` queries

1.0.0
latest
Source
npm
Version published
Weekly downloads
8
100%
Maintainers
0
Weekly downloads
 
Created
Source

tailwindcss-device

TailwindCSS plugin to add variants for input device detection using @media queries

Installation

pnpm

pnpm add -D tailwindcss-device

npm

npm i -D tailwindcss-device

yarn

yarn add -D tailwindcss-device

Usage

The plugin comes in two versions: One is CSS and meant for tailwind

With v4

There're two options for v4:

  • Add plugin to your tailwind.css file using the @import directive, like this:
@import "tailwindcss";

@import "tailwindcss-device"; /* <- This will import CSS version of the plugin */
  • Or use its JavaScript version via @plugin directive:
@import "tailwindcss";

@plugin "tailwindcss-device"; /* <- This will use legacy JavaScript version */

With v3

  • Add plugin to your tailwind.config.js plugins section:
import device from "tailwindcss-device"

export default {
  plugins: [
    device,
    // ...

    // or with custom prefix:
    deivce({prefix: "device"})
  ]
}
  • And then prefix utilities using available variants:
<div class="border border-black rounded-md device-touch:rounded-lg">
  <div class="hidden device-touch:block">
    Hello, I'm visible on smartphones and tables!
  </div>
  <div class="hidden device-desktop:block">
    Hello, I'm visible on computer with mouse!
  </div>
<div>
  • The result will look like this:
.hidden {
  display: none;
}

@media (pointer: coarse) {
  .device-touch\:block {
    display: block;
  }
}

@media (pointer: fine) or (pointer: none) {
  .device-desktop\:block {
    display: block;
  }
}

Available variants

NameTarget
touchDevices with touchscreen as primary input method (e.g smartphones and tablets)
desktopComputers with a mouse
desktop-touchComputers with touch input device
desktop-anyComputers with or without touch input device

Keywords

tailwindcss

FAQs

Package last updated on 29 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts